import javax.imageio.ImageIO;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import java.awt.geom.AffineTransform;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.stream.Stream;
import java.util.List;
import java.util.ArrayList;
import static java.util.stream.Collectors.toList;
import java.io.Console;

public class Resize {
  private static String[] acceptedImageTypes = {"png", "jpg", "jpeg"};
  private static List<String> resizedFilePaths;
  private static String RESIZE_FOLDER_PATH = "./resized-images/";

  public static void main(String[] args) {
      createResizedFolder();
      loadResizedFiles();

      System.out.println("Resizing images...");
      File folder = new File("./images");
      Stream.of(folder.listFiles())
            .filter(Resize::shouldBeResized)
            .forEach(Resize::processImage);

      System.out.println("Done.");

      Console c = System.console();
      if (c != null) {
          c.format("\nPress ENTER to exit.\n");
          c.readLine();
      }
  }

  private static void loadResizedFiles() {
    File resizedFolder = new File(RESIZE_FOLDER_PATH);
    try {
      resizedFilePaths = Stream.of(resizedFolder.listFiles())
            .map(file -> file.getName())
            .collect(toList());
    } catch(Exception e) {
      resizedFilePaths = new ArrayList<>();
    }
  }

  private static void processImage(File imageFile) {
    try {
      BufferedImage image = ImageIO.read(imageFile);

      int newWidth = Resize.getNewWidth(image.getWidth(), image.getHeight());
      int newHeight = Resize.getNewHeight(image.getWidth(), image.getHeight());
      BufferedImage scaled = Resize.resizeImage(image, newWidth, newHeight);
      Resize.save(scaled, imageFile.getName());
    } catch (IOException e) {
    }
  }

  private static int getNewWidth(int width, int height) {
    double aspectRatio = 0.75;
    double quotient = width / height;
    if (quotient < aspectRatio) {
      return (int) (height * 3 / 4);
    } else {
      return width;
    }
  }

  private static int getNewHeight(int width, int height) {
    double aspectRatio = 0.75;
    double quotient = width / height;
    if (quotient > aspectRatio) {
      return (int) (width * 4 / 3);
    } else {
      return height;
    }
  }

  private static boolean isImage(File file) {
    String path = file.getName();
    String fileEnding = path.substring(path.lastIndexOf('.') + 1);
    return Stream.of(acceptedImageTypes).anyMatch(x -> x.equals(fileEnding.toLowerCase()));
  }

  private static boolean isResized(File file) {
    return resizedFilePaths.contains(file.getName());
  }

  private static boolean shouldBeResized(File file) {
    return isImage(file) && !isResized(file);
  }

  private static void createResizedFolder() {
    File folder = new File("./" + RESIZE_FOLDER_PATH);

    if (!folder.exists()) {
      try {
        folder.mkdir();
      } catch (SecurityException se) {
        System.out.println("No privilege to create folder: " + RESIZE_FOLDER_PATH);
      }
    }
  }

  private static void save(RenderedImage image, String imagePath) throws IOException {
    String name = imagePath.split("\\.")[0];
    String ending = imagePath.substring(imagePath.lastIndexOf('.'));
    ImageIO.write(image, "png", new File(RESIZE_FOLDER_PATH + name + ending));
  }

  public static BufferedImage resizeImage(BufferedImage sourceImage, Integer newWidth, Integer newHeight) {
    int srcWidth = sourceImage.getWidth();
    int srcHeight = sourceImage.getHeight();
    BufferedImage resizedImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = resizedImage.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2d.drawImage(sourceImage, (newWidth - srcWidth) / 2, (newHeight - srcHeight) / 2, srcWidth, srcHeight, null);
    g2d.dispose();
    return resizedImage;
  }

}

@@ -507,24 +507,30 @@
 vate static 
+final 
 String RESIZ
@@ -565,16 +565,67 @@
 mages/%22;
+%0A  private static final double ASPECT_RATIO = 0.75;
 %0A%0A  publ
@@ -1565,59 +1565,146 @@
     
-int newWidth = Resize.getNewWidth(image.getWidth(),
+double quotient = image.getWidth() / image.getHeight();%0A      int newWidth = quotient %3C ASPECT_RATIO ? (int) (image.getHeight() * 3 / 4) :
  ima
@@ -1705,32 +1705,30 @@
  : image.get
-Height()
+Width(
 );%0A      int
@@ -1744,27 +1744,40 @@
 t = 
-Resize.getNewHeight
+quotient %3E ASPECT_RATIO ? (int) 
 (ima
@@ -1789,17 +1789,27 @@
 tWidth()
-,
+ * 4 / 3) :
  image.g
@@ -1818,17 +1818,16 @@
 Height()
-)
 ;%0A      
@@ -1990,493 +1990,8 @@
  %7D%0A%0A
-  private static int getNewWidth(int width, int height) %7B%0A    double aspectRatio = 0.75;%0A    double quotient = width / height;%0A    if (quotient %3C aspectRatio) %7B%0A      return (int) (height * 3 / 4);%0A    %7D else %7B%0A      return width;%0A    %7D%0A  %7D%0A%0A  private static int getNewHeight(int width, int height) %7B%0A    double aspectRatio = 0.75;%0A    double quotient = width / height;%0A    if (quotient %3E aspectRatio) %7B%0A      return (int) (width * 4 / 3);%0A    %7D else %7B%0A      return height;%0A    %7D%0A  %7D%0A%0A
   pr
@@ -2846,114 +2846,49 @@
    S
-tring name = imagePath.split(%22%5C%5C.%22)%5B0%5D;%0A    String ending = imagePath.substring(imagePath.lastIndexOf('.')
+ystem.out.println(imagePath + %22 resized.%22
 );%0A 
@@ -2952,21 +2952,17 @@
 H + 
-name + ending
+imagePath
 ));%0A

Fix filename parser bug