Created
July 1, 2019 05:44
-
-
Save azinkey/65ce43f6a658a8f6596c943238b73633 to your computer and use it in GitHub Desktop.
getimagesize Alternative (Faster alrternate Method)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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