0

Following code gives org.im4java.core.CommandException: org.im4java.core.CommandException: return code: 1 I am trying to compare two colors. what is wrong in my code or what is the correct solution to compare colors.

    ImageCommand compare=new ImageCommand();
    compare.setCommand("compare");
    IMOperation op = new IMOperation();
    op.fuzz(30.0);
    op.metric("AE");
    op.addImage();
    op.addImage();
    op.addImage();

    compare.run(op,"xc:green","xc:brown","null:");

1 Answers1

0

It's because ImageMagick's compare will return a non-zero exit code if the images are dissimilar. But the comparison should be working, the resulting difference image (3rd argument) is correctly generated.

It's however a problem for im4java because that's considered an error exit code, and there's no way as far as I know to tell im4java that it's not. See this discussion for more details.

You can work around it by catching the exception and ignoring it if the return code was 1 (compare should return 2 in case of error).

Nico
  • 811
  • 10
  • 18