|
@@ -9,8 +9,12 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
import javax.imageio.ImageIO;
|
|
|
|
+import javax.imageio.ImageReadParam;
|
|
|
|
+import javax.imageio.ImageReader;
|
|
|
|
+import javax.imageio.stream.ImageInputStream;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by owen on 2022/3/23 0023 17:48
|
|
* Created by owen on 2022/3/23 0023 17:48
|
|
@@ -71,7 +75,7 @@ public class ImgUtils {
|
|
*/
|
|
*/
|
|
public static void checkImgRatio(MultipartFile file){
|
|
public static void checkImgRatio(MultipartFile file){
|
|
try {
|
|
try {
|
|
-
|
|
|
|
|
|
+ ImageIO.setUseCache(false);
|
|
BufferedImage read = ImageIO.read(file.getInputStream());
|
|
BufferedImage read = ImageIO.read(file.getInputStream());
|
|
int width = read.getWidth();
|
|
int width = read.getWidth();
|
|
int height = read.getHeight();
|
|
int height = read.getHeight();
|
|
@@ -85,4 +89,7 @@ public class ImgUtils {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|