0

I want to get width and height of an images from url, but it doesn't work. it said

Warning: getimagesize(https://scontent-b-sin.xx.fbcdn.net/hphotos-xpa1/t1.0-9/156922_131613136994348_1325598195_n.jpg) [function.getimagesize]: failed to open stream: Invalid argument in D:\AppServ\www\test\test6.php on line 4

PHP

    $url = "https://scontent-b-sin.xx.fbcdn.net/hphotos-xpa1/t1.0-9/156922_131613136994348_1325598195_n.jpg";
    list($width, $height, $type, $attr) = getimagesize($url);

  echo "Image width " . $width ."<br />";
  echo "Image height " . $height ."<br />";
  echo "Image type " . $type ."<br />";
  echo "Attribute " . $attr ."<br />";

?>

Using path from my computer is work. what's happened? Thank you.

Marcus
  • 295
  • 4
  • 16
  • 3
    Can you please lookup `phpinfo();` the part where it says `Registered PHP Streams`,.. there must be in the following: `https, http and compress.zlib` and to be sure, can you test this with an image in the same folder as your PHP script and try that local picture? – Daniel W. Jul 11 '14 at 10:39
  • 1
    getimagesize response is very slow try the solution below. http://stackoverflow.com/questions/4635936/super-fast-getimagesize-in-php – Azhar Muhammad Jul 11 '14 at 10:46
  • @DanFromGermany path of an image in the same folder and local are work. It doesn't for only for URL from the web. – Marcus Jul 11 '14 at 11:03

1 Answers1

-2

First, to test if file exist use file_exists function. Also, you test your url with curl functions.

Mihai8
  • 3,113
  • 1
  • 21
  • 31