Re: Drawing Images Without Writing To a File
| From: | Ken Sande | Date: | Thu, 11 Mar 2010 15:40:53 +0000 |
| Subject: | Re: Drawing Images Without Writing To a File | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302703@lists.php.net to get a copy of this message | ||
Floyd Resler wrote:
I want to draw tabs in a tab bar without having to actually write the images to a file. Is it possible to generate the image and send the data back and make the browser think it's loading an image file? I know this can be done by sending the proper headers back for an entire page, but I just want to do basically the same thing for just part of the page. Thanks! FloydI do something similar with my googled webcam :) Then you just use the script as the source for your image (i.e. src="img.php?arguments"). Hopefully this is what you are looking for. (Note, this uses the processor pretty heavily when I run 100 images or so). If you are going to reuse the images for many clients, it may be a better alternative to reuse the generated image. <?php header("Content-type: image/jpeg"); $file = $_GET[src]; //"img/south-lawn1.jpg"; $imgfile = "img/" . $file; $fsize = filesize($file); $string = "South Lawn @ " . date("Y-m-d H:i:s", filemtime($file));
$im = imagecreatefromjpeg($file);$color = imagecolorallocate($im, 240, 240, 0);
$px = (imagesx($im) - 9.5 * strlen($string));$py = (imagesy($im) - 24); imagestring($im, 5, $px, $py, $string, $color); imagestring($im, 5, 10, $py, $file, $color); imagestring($im, 5, 10, $py - 16, round(( $fsize / 1024 ),1) . "kB", $color); imagejpeg($im); imagedestroy($im); ?> === 73, Ken Sande/KC8QNI-T