Here is a snippet of code on how to use it.
var convertCmd = createObject("java", "org.im4java.core.ConvertCmd").init();
/* search path: where imagemagick is located (on linux, it can usually be found in path) */
convertCmd.setSearchPath("C:\ImageMagick-6.7.9-Q16\");
var operation = createObject("java", "org.im4java.core.IMOperation").init();
operation.addImage([arguments.image]);
operation.colorspace("RGB");
/* for JPG, add the quality */
if (newExt eq "jpg")
{
var quality = structKeyExists(arguments, "quality") ? arguments.quality : "";
if (not isNumeric(quality) or quality eq 0)
{
quality = variables.defaultJPGQuality;
} else if (quality lt 1)
{
quality = quality*100;
}
operation.quality(javaCast('java.lang.Double', quality));
}
// Support for a transparency fillcolor
if (structKeyExists(size, "background"))
{
operation.background(size.background);
operation.flatten();
}
/* rotation? */
if (doRotate)
{
operation.rotate(toString(size.rotation));
}
/* crop? */
if (doCrop)
{
operation.crop(arguments.width, arguments.height, 0, 0);
/* resize */
} else {
operation.resize(JavaCast('int', arguments.width), javaCast('int', arguments.height));
}
/* grayscale ? */
if (structKeyExists(arguments, "grayscale") and arguments.grayscale eq true)
{
operation.colorspace("gray");
} else
{
operation.colorspace("sRGB");
}
// save the new file to a temp location
var tempImagePath = getTempDirectory() & createUUID() & ".#newExt#";
operation.addImage([tempImagePath]);
convertCmd.run(operation, []);
return tempImagePath;