I am trying to parse a html page to find the most prominent image. So, after parsing the html page to extract all img tags, i am trying to find the largest image by comparing the dimension of the image.
Is it right to compare the images by calculating the area as (width * height)?
That depends entirely on your definition of ‘largest’.
width * heightis certainly a valid approach, but it has the flaw that a 1×1000 image is ‘larger’ than a 30×30 one even though the latter could very well be more noticeable. It also has the problem that a large image that’s mostly the same as the background color will be more ‘noticeable’ than a medium image that isn’t, which might not be the case.In order to figure out how to determine how to find the ‘largest’ image, you need to specify why you want it.