note 13751 added to function.getimagesize.php
| From: | farinspaceNO_SPAM at hotmailNO_SPAM dot com | Date: | Sun, 01 Jul 2001 18:09:55 +0000 |
| Subject: | note 13751 added to function.getimagesize.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14839@lists.php.net to get a copy of this message | ||
I found I could check for image existence with the following:
// if img exists
if($img = @GetImageSize ("img.gif")) { echo "yes"; }
else { echo "no"; }
//sample code
if($img = @GetImageSize ("img.gif")) {
echo "<b>Image exsists</b>";
// return image width
echo "width = $img[0]";
// return image height
echo "height = $img[1]";
//return image type
switch ($img[2]) {
case 1:
echo "type = GIF";
break;
case 2:
echo "type = JPG";
break;
case 3:
echo "type = PNG";
break;
case 4:
echo "type = SWF";
break;
}
// return string width x height
echo "width x height = $img[3]";
}
else { echo "Image does not exsist"; }
http://www.php.net/manual/en/function.getimagesize.php