| We can
use translators in all kinds of server-side graphics.
Using an image placeholder allows us to render more
effectively in the design view what our actual page
will look like when displayed.
As with the counter example, the generation of
server-side graphics is expensive in terms of CPU
requirements. One area where we can speed up our
application is the caching of the chart. In most
applications the server-side chart does not need
to be real time. We could add in some logic to
only generate the chart once a day. We could alternatively
have an update button on the web site to force
the regeneration of the chart. In all other cases
we’d show the one on disk. Each application
will have its own specific requirements.
The other area that affects performance is the
size of the chart. A 300x150 chart uses much less
memory than a 600x300 chart. Use the smallest size
you can while preserving the clarity and integrity
of the chart.
Summary
In this chapter we've explored the basics of graphics.
We've seen different types of image formats,
in particular GIF, JPG, and PNG. We've also seen
how PHP interprets images in memory with a coordinate
system. We've covered transparency, an important
benefit in Internet graphics.
We took a short look at the GD API and focused
on four main areas:
- The Basic Functions
- Working with Color
- Creating Primitive Shapes
- Working with Text
We then used those functions in several applications.
We looked at a design time use of GD in generating
buttons for a toolbar on a web site. We compared
and contrasted a GD- and non GD-based approach
to implementing a counter. We concluded with a
server-generated graph with the JpGraph library.
We then explored how to translate server-side
code into a renderable entity in design view. We
used a translator to extract the relevant data
and placed it into an image placeholder. Then design
view rendered a box to fill the space of the actual
graphic.
This article is an excerpt of chapter 12 of “Dreamweaver
MX: Advanced PHP Web Development” by Gareth
Downes-Powell, Tim Green, Allan Kent, Bruno Mairlot,
George McLachlan, Dan Radigan, published January
2003 by glasshaus,
isbn 1904151191, as part of the dreamweaver
pro series. All rights reserved.
|