note 20036 deleted from function.getimagesize by didou
| From: | didou@php.net | Date: | Thu, 19 Jun 2003 15:23:57 +0000 |
| Subject: | note 20036 deleted from function.getimagesize by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-50656@lists.php.net to get a copy of this message | ||
Note Submitter: nospam.jemore@nospam.m6net.fr
----
A simple function to get the size of a gif image, without GD lib or without loading all the image :
function GetGifSize($filename, &$width, &$height)
{
DEFINE('GIFBUFSIZE', 10);
@set_magic_quotes_runtime(0);
$fd = fopen($filename, 'rb');
$a = fread($fd, GIFBUFSIZE);
fclose($fd);
@set_magic_quotes_runtime(get_magic_quotes_gpc());
if ((ord($a[0]) == 0x47) && (ord($a[1]) == 0x49) && (ord($a[2]) == 0x46)) //
'GIF'
{
$width = ord($a[7]) * 256 + ord($a[6]);
$height = ord($a[9]) * 256 + ord($a[8]);
return true;
}
else
return false;
}