image - Super fast getimagesize in php -


I'm trying to get image size (image dimension, width and height) of hundreds of remote images and it is very slow

I have done some reading and have found that the fastest way to read some bytes of pictures and check the size within binary data will be used.

Has anyone tried before? How do I check different formats? Has anyone seen any library for this?

"post-text" itemprop = "text">
  function ranger ($ url) {$ headers = array ("range: bytes = 0-32768"); $ Curl = curl_init ($ url); Curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ header); Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); $ Data = curl_xax ($ curl); Curl_close ($ curl); $ Return data; } $ Start = microtime (true); $ Url = "http://news.softpedia.com/images/news2/Debian-Turns-15-2.jpeg"; $ Raw = Ranger ($ url); $ Im = imagecreatefromstring ($ raw); $ Width = imagesx ($ im); $ Height = images ($ IM); $ Stop = round (microtom (true) - $ start, 5); $ Width echo "X". $ Height "({$ Stop} s)";  

test ...

640 x 480 (0.20859s)

To load 32kb of data Worked for me.


Comments