-3

I am trying to figure out ways to determine whether the url I am passing is an image or not. I have thought using getimagesize() to accomplish this task. But the main problem is, what if I want to check the image size of an encrypted image such as this url (https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTup5KSMveqkgrDKZR6p-0ANhPkJ7srbJOlKR78DUqqh85I_3MUrw)?

I am always getting this error:

Warning: getimagesize(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\series\index.php on line 4

Warning: getimagesize(https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTup5KSMveqkgrDKZR6p-0ANhPkJ7srbJOlKR78DUqqh85I_3MUrw): failed to open stream: No such file or directory in C:\xampp\htdocs\folder\index.php on line 4 0

user3135626
  • 87
  • 1
  • 7
  • 1
    If you cannot access the resource corresponding to the URL, you have no way of determining what type of content it corresponds to. – Oliver Charlesworth Dec 29 '13 at 02:55
  • 1
    possible duplicate of [Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?](http://stackoverflow.com/questions/5444249/unable-to-find-the-wrapper-https-did-you-forget-to-enable-it-when-you-config) – mario Dec 29 '13 at 02:57
  • Then how would you solved this issue? – user3135626 Dec 29 '13 at 03:21
  • save it locally then use getimagesize –  Dec 29 '13 at 03:32

1 Answers1

0

Couple of bits:

If you are running PHP5 (or could do) then you can use the HTTP Stream wrapper with the php.ini setting 'allow_url_fopen' set to on: This will allow you to do a 'straight forward' copy of any remote data to your server for processing.

e.g

<?php copy('https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTup5KSMveqkgrDKZR6p-0ANhPkJ7srbJOlKR78DUqqh85I_3MUrw', 'FileName.jpg'); ?>

Then you can do:

 <?php
    $size = getimagesize("FileName.jpg");
    echo $size;
    /*delete temp file*/
    unlink("FileName.jpg");
 ?>

Obviously not complete - but you can see the theory there

Paul
  • 45
  • 1
  • 9