use of org.im4java.core.CompareCmd in project selenium_java by sergueik.
the class VisualTest method compareImagesWithImageMagick.
// ImageMagick Compare Method
public void compareImagesWithImageMagick(String expected, String actual, String difference) throws Exception {
ProcessStarter.setGlobalSearchPath(imageMagickPath);
CompareCmd compare = new CompareCmd();
compare.setSearchPath(imageMagickPath);
// fix java.lang.NullPointerExceptionTests
// compare.setErrorConsumer(StandardStream.STDERR);
IMOperation imOperation = new IMOperation();
imOperation.fuzz(5.0);
// The special "-metric" setting of 'AE' (short for "Absolute Error" count),
// will report (to standard error),
// a count of the actual number of pixels that were masked, at the current
// fuzz factor.
imOperation.metric("AE");
// Add the expected image
imOperation.addImage(expected);
// Add the actual image
imOperation.addImage(actual);
// This stores the difference
imOperation.addImage(difference);
String script = "myscript";
try {
System.out.println("Comparison Started");
compare.createScript(script, imOperation);
System.out.println("Comparison Script written to " + script);
compare.run(imOperation);
} catch (CommandException ex) {
// ignore
System.err.println("Exception (ignored):" + ex.getClass());
System.err.print(ex);
} catch (Exception ex) {
System.err.println("Comparison Failed!");
System.err.print(ex);
throw ex;
}
// Put the difference image to the global differences folder
Files.copy(differenceImageFile, differenceFileForParent);
}
Aggregations