我正在尝试使用 im4java 和 gm4java 进行 GraphicsMagick 比较。我使用的 GraphicsMagick 命令是这样的:
gm compare -maximum-error 0 -metric MAE -highlight-style xor -hilight-color red -file C:/output/diffFile.pdf C:/input/file1.pdf C:/input/file2.pdf
我正在尝试将其翻译成 Java。我知道 im4java 最初是为 ImageMagick 构建的,它们的命令可能会有所不同。是否可以使用 im4java 加 gm4java 运行上述比较?
我试过这个:
SimpleGMService service = new SimpleGMService();
service.setGMPath("C:/path/to/graphicsMagick/gm.exe");
try
{
GMConnection connection = service.getConnection();
try {
GMBatchCommand command = new GMBatchCommand(service, "compare");
// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.metric("MAE");
op.addRawArgs("-file C:/output/diffFile.pdf");
op.addImage();
op.addImage();
ArrayListOutputConsumer output = new ArrayListOutputConsumer();
command.setOutputConsumer(output);
//debug
command.createScript("C:/output/myscript.bat",op);
command.run(op, "C:/input/file1.pdf", "C:/input/file2.pdf");
....
以上给了我错误:
org.im4java.core.CommandException: compare: Unrecognized option (-file C:/output/diffFile.pdf)