// Do the scaling
IMOperation scaleOp = new IMOperation();
scaleOp.addImage(originalFile.getAbsolutePath());
scaleOp.resize((int) scaledWidth, (int) scaledHeight);
scaleOp.addImage(scaledFile.getAbsolutePath());
imageMagick.run(scaleOp);
finalFile = scaledFile;
// Cropping
cropX = (int) Math.max(cropX, Math.ceil(ImageStyleUtils.getCropX(scaledWidth, scaledHeight, style)));
cropY = (int) Math.max(cropY, Math.ceil(ImageStyleUtils.getCropY(scaledWidth, scaledHeight, style)));