Citation :
Some formats may contain no image or may contain multiple images. In these cases, getimagesize() might not be able to properly determine the image size. getimagesize() will return zero for width and height in these cases.
...
tightcode_nosp@m_hotmail
13-Mar-2002 08:16
If you are using a php version with the bug where GetImageSize returns nothing on certain types of jpeg images, the following replacement should solve the problem until you have upgraded.
It accuratly duplicates the 1st and 2nd array element which are the ones I personally needed. I however added the 4th array element and a crude implementation of the 3rd since some people may need the functionality or find it usefull.
I hopefully reformated the function to not be wordwrapped and it is worth noting that as it is written, it only will work on local files. Additional error checking may be wise.
Code :
- function sgetimagesize($filename) {
- $ftype_array = array(".gif"=>"1",
- ".jpg"=>"2",
- ".jpeg"=>"2",
- ".png"=>"3",
- ".swf"=>"4",
- ".psd"=>"5",
- ".bmp"=>"6" );
- if (is_file($filename)) {
- $fd = @fopen($filename,"r" );
- $image_string = fread($fd,filesize($filename));
- $im = ImageCreateFromString($image_string);
- $ftype = $ftype_array[get_file_ext($filename)];
- $gis[0] = ImageSX($im);
- $gis[1] = ImageSY($im);
- $gis[2] = ($ftype?$ftype:"0" );
- $gis[3] = "width={$gis[0]} height={$gis[1]}";
- ImageDestroy($im);
- return $gis_array;
- }
- else { return false; }
- }
|
Cheers,
Tightcode
pekka at SPAMphotography-on-theSPAM dot net
26-Feb-2003 02:44
If you have problems making getimagesize work in PHP 4.3 or 4.3.1, using the optional parameter will kick it alive again.
i.e. $x = getimagesize($url,$info); instead of $x = getimagesize($url);
|