Home Tutorial Php Phpgd PHP gd caching an image

 
 

Share on Google+Share on Google+
PHP gd caching an image
Posted on: November 2, 2009 at 12:00 AM
Advertisement
This example shows how to display caching of an image.

<?php

header("Content-type: image/png");

$filename = date("Y_m_d").".png";

if (is_file($filename)) {

readfile($filename);

exit;

}

$image = imagecreatetruecolor(100,25);

$white = imagecolorallocate($image,255,255,255);

$black = imagecolorallocate($image,0,0,0);

imagefill($image,0,0,$white);

imagerectangle($image,0,0,99,24,$black);

imagestring($image,5,5,5,date("d/m/Y"),$black);

imagepng($image,$filename);

imagepng($image);

imagedestroy($image);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP gd caching an image:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 2, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com