note 37531 deleted from function.getimagesize by cmb
| From: | cmb@php.net | Date: | Sun, 18 Dec 2016 09:44:32 +0000 |
| Subject: | note 37531 deleted from function.getimagesize by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208639@lists.php.net to get a copy of this message | ||
Note Submitter: djwishbone at hotmail dot com
----
Using remote files with getimagesize($URL) never worked for me. Except when I would grab files from
the same server. However, I developed some code with the help from the people here that does work.
If you are having problems give this function a shot:
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;
}
goodluck