Super fast getimagesize in php

function ranger($url){
$headers = array(
“Range: bytes=0-32768”

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
return $data;

$start = microtime(true);

$url = “”;

$raw = ranger($url);
$im = imagecreatefromstring($raw);

$width = imagesx($im);
$height = imagesy($im);

$stop = round(microtime(true) – $start, 5);

echo $width.” x “.$height.” ({$stop}s)”;


One thought on “Super fast getimagesize in php

  1. Thanks again for a great post, and for everything, I am learning more from you than you know and I think I am growing my blog and my brand quite well as a result, so thanks mate.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s