I have two images which I want to compare with the ImageMagick Java wrapper 'im4java'. As far I have this piece of code:
boolean compare (String picture1, String picture2) {
boolean pdfsEqual;
IMOperation imOperation = new IMOperation();
imOperation.metric("ae");
imOperation.addImage();
imOperation.addImage();
imOperation.addImage();
CompareCmd compare = new CompareCmd();
ArrayListOutputConsumer outputConsumer = new ArrayListOutputConsumer();
compare.setOutputConsumer(outputConsumer);
try{
compare.run(imOperation, pathSample, pathResult, "null:");
pdfsEqual = true;
} catch (Exception e){
pdfsEqual = false;
ArrayList<String> stringArrayList = outputConsumer.getOutput();
System.out.println(stringArrayList);
}
return pdfsEqual;
}
But the stringArrayList
is empty. Reading im4java
documentation I found that actually the OutputConsumer
stores the output in an array list but as already said there is nothing. Also, imOperation.metric("ae")
counts the pixels that are different between the two images and prints it to the console if the call has been done from command prompt itself. I can't figure out how I can get this number of diff pixels in my java code using the OutputConsumer
.