我正在尝试通过 IM4Java 库使用 Image Magick 调整图像大小。
它工作得很好,除了图像没有居中。我已经通过外部命令行运行了这些相同的命令,它们运行良好。
谁能告诉我为什么这不起作用?
private void convertImage(int width, int height, String source, String dest)
throws IOException, IM4JavaException, InterruptedException
{
// create command
ConvertCmd cmd = new ConvertCmd();
// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.addImage(source);
op.thumbnail(width, height, ">");
op.extent(width, height);
op.gravity("center");
op.background("white");
op.addImage(dest);
ProcessStarter.setGlobalSearchPath("/usr/local/bin");
cmd.setOutputConsumer(imageMagickOutputter);
cmd.run(op);
}