FileCommonUtil { public static boolean resizeImage(String srcPath, String destPath, int newWidth, int newHeight, boolean forceSize) { try { if (forceSize) { Thumbnails.of(srcPath).forceSize(newWidth, newHeight).toFile(destPath); } else { Thumbnails.of(srcPath).width(newWidth).height(newHeight).toFile(destPath); } } catch (IOException e) { logger.error("resizeImage, IOException: [{}]", e); return false; } return true; }  static boolean isFileSizeLegal(int length, Double maxSize); static String generateMappingPath(String rootPath, String hash, String nameSuffix); static byte[] encryptImgXor(byte[] fileBytes, int xor); static String getContent(File file); static boolean resizeImage(String srcPath, String destPath, int newWidth, int newHeight, boolean forceSize); static boolean changeSize(String srcPath, String destPath, int newWidth, int newHeight); static boolean compressToTar(File inputFile, String outFilePath);  }
@Test public void resizeImage() { String srcPath = "C:\\Users\\Administrator\\Desktop\\test_img_store\\old\\AppIcon57x57.png"; String destPath = "C:\\Users\\Administrator\\Desktop\\test_img_store\\new\\1_AppIcon512x512.png"; FileCommonUtil.resizeImage(srcPath, destPath, 512, 512, true); }