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)?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This is the only way I think , and its works fine. Thank you friend

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.