| | |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | public static void main(String[] args) { |
| | | compressAllFiles(new File("/usr/local/ftp/member/20240317"),800); |
| | | // compressAllFiles(new File("D://visit")); |
| | | // compressAllFiles(new File("/usr/local/ftp/member/20240317"),800); |
| | | compressAllFiles(new File("D://visit"),1100); |
| | | } |
| | | public static void compressAllFiles(File folder ,int w) { |
| | | File[] files = folder.listFiles(); |
| | |
| | | long originalFileSize = file.length(); |
| | | BufferedImage originalImage = ImageIO.read(file); |
| | | double compressionRatio = (double) originalFileSize / (200 * 1024.0); |
| | | if (compressionRatio > 1 && originalImage.getWidth()>w) { |
| | | if (compressionRatio >= 1 ) { |
| | | System.out.println("==========================="+compressionRatio); |
| | | // int compressedWidth = (int) (originalImage.getWidth() / compressionRatio); |
| | | // int compressedHeight = (int) (originalImage.getHeight() / compressionRatio); |
| | |
| | | ImageIO.write(compressedImage, "jpg", outputfile); |
| | | if(outputfile.length()<50 * 1024.0){ |
| | | resetOldfile(oldFile); |
| | | System.out.println("================小于50"); |
| | | } |
| | | } else { |
| | | //不处理 |
| | | System.out.println("================成功"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |