|
|
|
<?php
if(defined("image_cache.php")) {
return;
} else {
define("image_cache.php",1);
}
/*
=pod
=head1 NAME
Image Cache - Class to "cache" dynamically created images.
=head1 Dependencies
PHP with gd and png support compiled in.
=head1 SYNOPSIS
Example:
$image = new Image_Cache("this_image.png");
if($image->get()) {
$image->display();
}else{
//create a png named $png
$image->store($png);
$image->display();
}
=head1 DESCRIPTION
Basically, Image Cache writes dynamically created images to disk on the first access so that on
subsequent requests the image may be read from disk, rather than redrawn from computations. It also
has the ability to set a timeout on images so that they are recalculated after a certain duration.
=cut
*/
class Image_Cache {
/*
=pod
=head2 Varibles
=over 4
=item I<path>
The relative path to store cached images. This directory must be readable and writeable by the
webserver.
Default: ./dyn_images
=item I<image>
The full path to the cached image. Considered private.
Default: None. Should not be set other than by class!
=item I<Timeout>
Time, in seconds, that an image may reside on disc before being recalculated.
Default: 86400 (24 hours)
=back
=cut
*/
var $path = "./dyn_images/";
var $image;
var $Timeout = 86400;
/*
=pod
=head2 Methods
=over 4
=item I<Image_Cache>
Public constructor.
Arguments:
=over 4
title - Title of image to be cached. Should be unique.
Timeout - Time, in seconds, that an image may reside on disc before being recalculated. Default:
86400 (24 hours)
=back
Returns: nothing
Example:
=over 4
$image = new Image_Cache("thispage.png",360);
creates an Image Cache object with a timeout of 1 hour and a path of "./dyn_images/thispage.png".
$image = new Image_Cache("thispage.png");
creates an Image Cache object with a timeout of 24 hours and a path of "./dyn_images/thispage.png"
=back
=cut
*/
function Image_Cache($title = "",$Timeout = 86400) {
if($title) {
$title = urlencode($title);
$this->image = $this->path . $title;
}
$this->Timeout = $Timeout;
}
/*
=pod
=item I<get>
Determines if an image exists, and, if so, if it was created within the timeout.
Arguments: none
Returns: 1 if the image is valid, 0 if not.
=cut
*/
function get() {
if(is_readable($this->image)) {
$stat = stat($this->image);
if( (time() - $stat[9]) < $this->Timeout ) {
return 1;
}
}
return 0;
}
/*
=pod
=item I<store>
Stores a png to disk.
Arguments: The resource id of the image to be stored.
Returns: nonzero value if succesfull, 0 otherwise.
=cut
*/
function store($png) {
return imagepng($png,$this->image);
}
/*
=pod
=item I<display>
Handles the image output.
Arguments: none
Returns: nonzero value if succesfull, 0 otherwise.
=cut
*/
function display() {
$im = @imagecreatefrompng ($this->image);
return imagepng($im);
}
}
/*
=pod
=back
=head1 AUTHOR
M. Brian Akins, bakins@stsi.net
=cut
*/
?>
|
|
| crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | Render TTF Text to PNG. Text message, font, size, rotation, padding, color, background, and transparency can all be defined via URL. Categories : PHP, PHP Classes, Graphics | | | HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout. Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs | | | Three Cool Classes and One Trick Categories : PHP, PHP Classes, Graphics, Email | | | Advanced Image WaterMarker Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented | | | Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs | | | HTML_Graphs provides a simple PHP interface for
creating pure HTML charts. Categories : Graphics, PHP, PHP Classes, Charts and Graphs | | | 3dLib - a class for drawing in 3D space. Supported functions: Line, SetPixel, Polygon, FilledPolygon, etc. 3dChart() function has been added for one-call drawing of 3d charts. Support of mostly used 3d-transformations. Categories : Graphics, Math., PHP Classes, PHP, Charts and Graphs | | | imageMarker v 3.00 with new advanced features Categories : PHP, PHP Classes, Graphics, GD image library | | | PHP interface class to the eBusiness Charts generatation remote service. Categories : PHP, PHP Classes, Graphics, Charts and Graphs | | | Image Generation Class ( PNG Format ) Categories : PHP, GD image library, PHP Classes, Graphics | | | A class to draw real 3D graphics with surface area Categories : Graphics, PHP, PHP Classes | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | |
|
|
|