Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001122

[PHP] GD: how to show different types of images? From: Boulgakov Andrei (andrei.boulgakov <email protected>)
Date: 12/24/01

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);
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>