Page 1 of 1

Not able to get standard Picture size to compare two Images

Posted: 2015-01-11T19:30:22-07:00
by aryan05
All,
I am currently using Webdriver tool to get screenshot of a Webpage. I'm using Firefox browser to host the webapage.
The issue i am facing while comparing two images in ImageMagick is that the size of screenshots vary.

To overcome this, i explicitly try "convert" command and update Image to standard size like shown below .

convert "src/main/resources/Images/ImagesGoldenSet/Image.png" -resize 1024x1024 "src/main/resources/Images/ImagesGoldenSet/Image.png"

and then when I try to compare two images who have been converted as above, i still see the Image size varies minutely like shown below.

Image1 Size: PNG 324x1024 324x1024+0+0 16-bit sRGB 1.009MB 0.000u 0:00.000
Image2 Size: PNG 329x1024 329x1024+0+0 16-bit sRGB 967KB 0.016u 0:00.000

As you see above, both image sizes have 1024, but i still see a difference "324x1024" and "329x1024".

Question - How do i achieve a exact same Image size when converting and how do i overcome the 'compare' issue when size is slightly different.
Any other better way to achieve a solution.


Cheers

Re: Not able to get standard Picture size to compare two Images

Posted: 2015-01-11T19:59:19-07:00
by snibgo
Use "!" to force an exact resize. For example ...

Code: Select all

convert in.png -resize 1024x1024! out.png
... will make the output exactly 1024x1024 pixels.

For some shells, we need to escape the "!". For example, Windows BAT syntax:

Code: Select all

convert in.png -resize "1024x1024^!" out.png