|
|
@ -101,16 +101,10 @@ public class FileBatchUploadComponent { |
|
|
|
e.printStackTrace(); |
|
|
|
}*/ |
|
|
|
try { |
|
|
|
// 动态选择输出格式(根据源文件扩展名)
|
|
|
|
String outputFormat = suffixName.substring(1); // 去除点(.),比如 "jpg" -> "jpg"
|
|
|
|
/* // 读取图片的宽高,不加载整个图像到内存中
|
|
|
|
// 读取图片的宽高,不加载整个图像到内存中
|
|
|
|
BufferedImage thumbnail = Thumbnails.of(file.getInputStream()).size(1, 1).asBufferedImage(); |
|
|
|
width = String.valueOf(thumbnail.getWidth()); |
|
|
|
height = String.valueOf(thumbnail.getHeight());*/ |
|
|
|
BufferedImage thumbnail = Thumbnails.of(file.getInputStream()) |
|
|
|
.size(800, 600) // 限制最大宽度和高度
|
|
|
|
.outputFormat(outputFormat) // 设置输出格式
|
|
|
|
.asBufferedImage(); |
|
|
|
height = String.valueOf(thumbnail.getHeight()); |
|
|
|
// 处理宽高信息
|
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|