对于很多人来说,如何把大图片压缩成小图片,并且不会丢失原图的帧数,之前我也试过很多方法,其中包含了Aspose,JPEGImage,OpenCv等相关包,依然无法解决这个问题。
好了,废话不多说,直接上代码。
private static ArrayList<String> compressionImg(ArrayList<String> files, String newUrl) throws Exception {
ArrayList<String> urlList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(files)) {
Integer count = 0;
for (String file : files) {
File file1 = new File(file);
count += 1;
String newFileUrl = newUrl + UUIDUtil.getUUIDFor_id() + count + ".jpg";
if (!urlList.contains(newFileUrl)){
urlList.add(newFileUrl);
}
BufferedImage inputBufImage = ImageIO.read(file1);
MyImage myImage = new MyImage();
InputStream inp