Page 1 of 1

Issues comparing two images taken from webdriver screenshot

Posted: 2015-01-14T18:17:37-07:00
by aryan05
Hiya,
I am using Selenium Webdriver on firefox to take screenshots of webpages. its known thing that webdriver takes screenshots in different sizes each time.
1) To overcome the size issue, i am using convert command in Imagemagick to set to standard size of 1024x1024!
2) When i compare the images now, i dont get any issues with Image size, but when same two images are compared, i see there is little offset and entire difference is shown in red. as if entire page is different.

- I am not sure how to upload Image here....

command
------------
compare -metric AE Image1.png Image1-copy.png Diff.png

Is there a way i can overcome such issues. please check attached snapshot for reference.

Re: Issues comparing two images taken from webdriver screenshot

Posted: 2015-01-14T18:59:54-07:00
by fmw42
To provide images, you need to upload to some free hosting service such as dropbox.com and put the URL here. If your system takes images of different sizes, it may also take images that are differently offset. So you would need to register the two images using control points and use -distort affine to get them scaled, rotated and offset to match as good as you can before doing any compare.

If you use

Code: Select all

convert image1 image2 -compose difference -composite result
then the whiter the image, the more difference you have. The compare difference image will always show only a binary state, match perfectly or no match. With the -compose difference you can color code as well, such as

Code: Select all

convert image1 image2 -compose difference -composite +level-colors black,red result
or you can overlay the color where it differs onto the first image such that the more intense the red, the more different it is.

(unix syntax)

Code: Select all

convert image1 image2 \
\( -clone 0 -clone 1 -compose difference -composite \) \
\( -clone 0 -fill red -colorize 100% \) \
-delete 1 +swap -compose over -composite result

see
http://www.imagemagick.org/Usage/distorts/#affine
http://www.imagemagick.org/Usage/compose/#difference
http://www.imagemagick.org/Usage/color_ ... vel-colors

Also please always provide you version of Imagemagick and platform, when asking questions, because syntax may differ or there could be bugs in older versions of IM.