Skip to content

Instantly share code, notes, and snippets.

@azinkey
Created July 1, 2019 05:44
Show Gist options
  • Save azinkey/65ce43f6a658a8f6596c943238b73633 to your computer and use it in GitHub Desktop.
Save azinkey/65ce43f6a658a8f6596c943238b73633 to your computer and use it in GitHub Desktop.
getimagesize Alternative (Faster alrternate Method)
function getimagesizeAlt($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);
$gis[3] = "width={$gis[0]} height={$gis[1]}";
ImageDestroy($im);
return $gis;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment