I'm coding an application using Java and I need to resize some images, so I've been learning about ImageMagick. The command I need to use for my purposes is:
convert -resize 500x500\> -quality 85% -strip -interlace Plane -define jpeg:dot-method=float source.jpg destination.jpg
Using Java, I think I could use:
Runtime.getRuntime().exec(command);
Isn't it?
But, if I rather user an API like JMagick... how could I proceed to compose what I want to do?
Thank you very much! Regards.
After investigate and read a lot from IM4J API, I did this:
IMOperation op = new IMOperation();
op.resize(500, 500, '>');
op.quality(85.0); // jpeg quality (%)
op.strip(); // remove EXIF comments
op.interlace("Plane"); // progressive-mode
op.define("jpeg:dot-method=float"); // float processing (more quality, but slower)
op.addImage("my_original_pic.jpg");
op.addImage("my_resized_pic.jpg");
ConvertCmd convert = new ConvertCmd();
convert.run(op);
And that's all! :)
If you want to use mogrify command, you can re-use the IMOperation object and just have to do this:
MogrifyCmd mogrify = new MogrifyCmd();
mogrify.run(op);
But remember that mogrify command doesn't have a second pic input parameter.