Re: Drawing Images Without Writing To a File

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ken,
	That's exactly what I want and it works beautifully!  I wish I had asked this question a long time ago since, in the past, I have been creating the files and wind up with a bunch of image files hanging around.  When building this new site I thought there must be a better way!

Thanks!
Floyd

On Mar 11, 2010, at 10:40 AM, Ken Sande wrote:

> 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!
>> Floyd
> 
> I 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux