note 28298 added to function.imagetypes
| From: | jaldinger at rack1 dot php dot net | Date: | Wed, 08 Jan 2003 18:31:14 +0000 |
| Subject: | note 28298 added to function.imagetypes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41849@lists.php.net to get a copy of this message | ||
Please note that if only "GIF Read Support" is enabled, the
IMG_GIF bit will not be returned (at least on my system:
PHP 4.3.0/RH Linux 7.2).
To work around this issue, and also the issue that there is no
function that can tell me what image format a GD resource ID
refers to, I use the following switch statement to map the exif
IMAGETYPE_* constants to the GD IMG_* constants:
switch (exif_imagetype($file['tmp_name'])) {
case IMAGETYPE_GIF:
$image_type = IMG_GIF;
break;
case IMAGETYPE_JPEG:
$image_type = IMG_JPG;
break;
case IMAGETYPE_PNG:
$image_type = IMG_PNG;
break;
case IMAGETYPE_WBMP:
$image_type = IMG_WBMP;
break;
default:
$image_type = 0;
break;
}
store this value together with the image data in a database
and later use the following IF statement to see if I can work
with that image (create a thumbnail, etc...)
if ($image_type & (imagetypes() | IMG_GIF)) {
return $this->createJpegThumbailFromString($data, 46, 27);
} else {
return file_get_contents($_SERVER['DOCUMENT_ROOT'] .
'/gfx/no-thumbnail.jpg');
}
HTH anybody...
Joerg.
--
http://www.php.net/manual/en/function.imagetypes.php
http://master.php.net/manage/user-notes.php?action=edit+28298
http://master.php.net/manage/user-notes.php?action=delete+28298
http://master.php.net/manage/user-notes.php?action=reject+28298