}
public boolean cropImage(Image i, File outputFile, int top, int left, int width, int height) throws IOException {
try {
// create command
ConvertCmd cmd = new ConvertCmd();
// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.addImage(getFile(i).getPath());
op.crop(width, height, left, top);
op.addImage(outputFile.getPath());
cmd.run(op);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;