GD: how to show different types of images?
| From: | Boulgakov Andrei | Date: | Mon, 24 Dec 2001 07:34:43 +0000 |
| Subject: | GD: how to show different types of images? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-78641@lists.php.net to get a copy of this message | ||
Hi!
I have 2 types of images :PNG and Jpeg. They are w/o extension (its name
generated by tempnam and it is exported from DB). How can i show the both
in one script?
I tryed like this, but it doesn't work(i see one type, and error on
another):
$im = ImageCreateFromJpeg($picname);
$text="Some text";
if($im)
{
$nsi= ImageColorAllocate($im,255,190,0);
ImageString($im,3,0,0,$text,$nsi);
Header("Content-type: image/jpeg");
ImageJpeg($im);
ImageDestroy($im);
}
else
{
$im = ImageCreateFromPNG($picname);
$nsi= ImageColorAllocate($im,255,190,0);
ImageString($im,3,0,0,$text,$nsi);
Header("Content-type: image/png");
ImagePng($im);
ImageDestroy($im);
}