daveman
02-28-2004, 06:07 PM
Not sure where to go from here. getimagesize works fine on images stored on any site on the server. Thus site A can use it on site B. Once we try a site not hosted on the server it times out, no error from it though. The server however can wget the remote image with no problems. Any ideas?
Umbongo
02-28-2004, 09:05 PM
<?
function getimagesize_remote($image_url) {
$handle = fopen ($image_url, "rb");
$contents = "";
if ($handle) {
do {
$count += 1;
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while(true);
} else { return false; }
fclose ($handle);
$im = ImageCreateFromString($contents);
if (!$im) { return false; }
$gis[0] = ImageSX($im);
$gis[1] = ImageSY($im);
// array member 3 is used below to keep with current getimagesize standards
$gis[3] = "width={$gis[0]} height={$gis[1]}";
ImageDestroy($im);
return $gis;
}
?>
From the user comments on php.net manual. It worked for me.
daveman
02-28-2004, 09:28 PM
Hmm, that looks more resource intensive since it uses gd lib but not sure how much.
Umbongo
02-28-2004, 10:14 PM
That method while more resource intensive will always get the dimensions I think. Are you using the latest release of php? In previous builds there were problems with remote images working local but the exact same image not being able to be sized remotely. I thought it was fixed though.