get_headers takes too much time for checking size of image

1k Views Asked by At

hi i am using below code to check the size of remote image .it works but it takes lot of time to check the size of image is there any bette rway to do

<?php
  $url='http://testfile.com/test/sddkssk.jpg';
  $head = array_change_key_case(get_headers($url, TRUE));
  $filesize = $head['content-length'];
  if ($filesize >= 131000) {     
    echo 'good image';
  }

but it takes 2-3 minute for each time to load is there any better way which can do same work very fast

1

There are 1 best solutions below

2
On
$size = getimagesize("http://www.example.com/gifs/logo.gif");

// if the file name has space in it, encode it properly
$size = getimagesize("http://www.example.com/gifs/lo%20go.gif");