1

Can somebody guide as to how can I use image magick or jmagick in designing automation visualization testing.

Basically I want to automate comparison of screenshots(new with old) of web applications.

I have configured Selenium to run with junit core in eclipse. I am am still figuring how to use image magick with this configuration. Are there any links?

Any help is appreciated.

Andrea
  • 11,801
  • 17
  • 65
  • 72
Kevin
  • 217
  • 6
  • 19

1 Answers1

1

To visually compare a reference screenshot to a to-be-tested one with the most simple command, just run this one (or translate it into its equivalence in jmagick):

 compare reference.jpeg to-be-tested.jpeg -compose src diff.jpeg
  • If both are visually equal, your diff.jpeg will be a white image.
  • If both are visually different, the diff.pdf will mark differences with red pixels (while white pixels still mean: 'no difference here').

Example

On the right: the "Diff" image.

See also Imagemagick : “Diff” an Image.

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • can somebody present a small snippet of java code using image magick for comparing two images – Kevin Sep 21 '12 at 19:26
  • @chintanpathak: Before you ask for more, you should first start accepting+upvoting such answers to your questions which do solve the problem as it was posed initially... – Kurt Pfeifle Sep 21 '12 at 23:17
  • Thanks for the information, but I the know the compare function and how it is used in ImageMagick but I wonder if jmagick really use the "compare" or "difference" function of ImageMagick coz I can't find any related function here: http://downloads.jmagick.org/jmagick-doc/ Can somebody help!?!?!?!? – Kevin Sep 24 '12 at 16:21
  • @chintanpathak: I don't think there are a lot of other people willing to help if they see your record of refusing to upvote good answers... (after all, you asked specifically for ImageMagick too, and didn't **at all** indicate your claim *'I knew already'*.) – Kurt Pfeifle Sep 24 '12 at 18:25
  • I kept on reading things that why I mentioned that I knew aleady. Sorry about confusion, my English is not the greatest. I clicked on upvote button, is that what I suppose to do. – Kevin Sep 24 '12 at 20:25
  • Let me more specific on this. I am trying to generated diff image using compare function in jmagick and as I am newbee in Java, I have problem writing code. I found this String cmd = "compare -metric MSE "+file1+" "+file2+"tempImageDifference.jpg"; but don't know how to implement it to write the diff image to a specific location.. – Kevin Sep 24 '12 at 20:28
  • @chintanpathak: Using `-metric ...` does not write a diff image at all. It prints some string to stdout containing some *metric* information about the file differences. Which, of course, can also be a valid approach used in unit testing. Not necessarily alternatively to creating diff images, but as complementary to this... To create diff images you need to use something like the compare command parameters I gave. – Kurt Pfeifle Sep 24 '12 at 22:00
  • sorry about delayed response. I wonder if jmagick really use the "compare" or "difference" function of ImageMagick coz I can't find any related function here: http://downloads.jmagick.org/jmagick-doc/ – Kevin Oct 26 '12 at 18:33