Class: Cache_Graphics
Source Location: /Cache-1.5.5/Graphics.php
PEAR
|
--Cache
|
--Cache_Graphics
Graphics disk cache.
Author(s):
Version:
- $Id: Graphics.php,v 1.7 2005/01/26 09:47:28 dufuz Exp $
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
[line 72]
Graphics disk cache. The usual way to create images is to pass some arguments that describe the image to a script that dynamically creates an image. For every image of a page a new PHP interpreter gets started. This is a good way to kill your webserver. When dealing with dynamically generated images you should not call another script to generate the images but generate the images by the script that produces the page that contains the images. This is a major improvement but it's only half the way. There's no need to rerender an image on every request. A simple disk cache can reduce the computation time dramatically. This is what the class graphics_cache is for. Usage: // create an instance of the graphics cache $cache = new graphics_cache; $img = ImageCreate(...); // compute an ID for your image based on typical parameters $id = m5d( $size, $colors, $label); // check if it's cached if (!($link = $cache->getImageLink($id, 'gif'))) { // hmmm, it's not cached, create it ... // cacheImageLink() and cacheImage() make the ImageGIF() call! // cacheImage() returns the value of ImageGIF() [etc.], cacheImageLink() returns a URL $link = $cache->cacheImageLink($id, $img, 'gif'); } // Ok, let's build the ImageLink $size = getImageSize($link[0]); printf('<img src="%s" %s>', $link[1], $size[3]); // for cacheImage(): // header('Content-type: image/gif'); print $cache->cacheImage($id, $img, 'gif'); The class requires PHP 4.0.2+ [ImageType()]. Note that cacheImage() works with the output buffer. Modify it if required!
Class Variables
Method Detail
Documentation generated on Mon, 11 Mar 2019 15:25:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|