Re: GD Image Resizing on the fly.
| From: | denis | Date: | Fri, 19 Nov 2004 15:09:13 +0000 |
| Subject: | Re: GD Image Resizing on the fly. | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25003@lists.php.net to get a copy of this message | ||
hi
this the script i use in www.biere.org
you can see it in action at
http://www.monsieur-biere.com/liste/secondairelmc.php3?type=type&type2=BIERE+DE+NOEL&page=1
i use the same script in rhe shopping cart and in the order form
it test if the file exist and resize it at predefined size or peoduce a
single dot image transparent, it was easy to modify this script to your
needs
<? /* Header ("Content-type: image/png"); */
$imname="imagesb//".$ref.".png";
if (file_exists($imname)):
$im = ImageCreatefrompng($imname);
$rat=60.0*(doubleval(imagesx($im))/doubleval(imagesy($im)));
$im2 = ImageCreate($rat, 60);
imagecopyresized($im2,$im,0,0,0,0,$rat,60,imagesx($im),imagesy($im));
else:
$im2 = ImageCreate(1, 1);
$green = ImageColorAllocate($im2, 0, 255, 0);
imagefilledrectangle($im2,0,0,1,1,$green);
endif;
Imagepng($im2);
?>
denis