0

I scrap a webpage content using curl. And create DOM using that html content. I need to check size of the images that contained in that html.

Is that possible to width and height of an using Php DOM (image tag not containing the width and height attribute)?

hakre
  • 193,403
  • 52
  • 435
  • 836
Rahul PK
  • 270
  • 5
  • 22
  • You might be also interested in [How to determine the size of an image without downloading it (in full)?](http://stackoverflow.com/q/7452896/367456) and similar Q&A. – hakre Jun 23 '13 at 23:01

1 Answers1

4

As you are saying img tag is not containing height & width. You can look at getimagesize PHP function. You need to pass image url you getting from scrapping to getimagesize function.

Ex:

<?php 

   $size = getimagesize("http://static.php.net/www.php.net/images/php.gif");          

   print_r($size);
?>

OUTPUT is array

Array
(
[0] => 120
[1] => 67
[2] => 1
[3] => width="120" height="67"
[bits] => 7
[channels] => 3
[mime] => image/gif
)

Hope this help.

metalfight - user868766
  • 2,722
  • 1
  • 16
  • 20