public static void resize(File file, int width, int height) throws FileOperationException {
   BufferedImage image;
   try {
     image = ImageIO.read(file);
     image = Scalr.resize(image, Scalr.Method.ULTRA_QUALITY, Scalr.Mode.FIT_EXACT, width, height);
     saveToJPG(image, file);
     image.flush();
   } catch (IOException | IllegalArgumentException e) {
     logger.error(e.getMessage(), e);
     throw new FileOperationException("Resizing failed");
   }
 }
 public static void crop(File file, int x, int y, int width, int height)
     throws FileOperationException {
   BufferedImage image;
   try {
     image = ImageIO.read(file);
     image = Scalr.crop(image, x, y, width, height);
     saveToJPG(image, file);
     image.flush();
   } catch (IOException | IllegalArgumentException e) {
     logger.error(e.getMessage(), e);
     throw new FileOperationException("Cropping failed");
   }
 }