|
|
@ -201,7 +201,9 @@ public class FileBatchUploadComponent { |
|
|
|
|
|
|
|
// 使用 Thumbnailator 压缩图片
|
|
|
|
int quality = 100; // 初始质量为100(即不压缩)
|
|
|
|
// 在这里添加缩放设置
|
|
|
|
Thumbnails.of(inputStream) |
|
|
|
.size(1024, 1024) // 设置图片最大宽度和高度为1024px
|
|
|
|
.outputQuality(quality / 100.0) // 设置输出质量
|
|
|
|
.toOutputStream(outputStream); |
|
|
|
|
|
|
@ -211,6 +213,7 @@ public class FileBatchUploadComponent { |
|
|
|
outputStream.reset(); // 清空输出流
|
|
|
|
|
|
|
|
Thumbnails.of(inputStream) |
|
|
|
.size(1024, 1024) // 保持尺寸不变
|
|
|
|
.outputQuality(quality / 100.0) |
|
|
|
.toOutputStream(outputStream); |
|
|
|
|
|
|
@ -240,9 +243,6 @@ public class FileBatchUploadComponent { |
|
|
|
if (file.getSize() == 0) { |
|
|
|
return rm.setMsg("上传文件不能为空"); |
|
|
|
} |
|
|
|
//文件大小
|
|
|
|
// long size = file.getSize();
|
|
|
|
// String fileSize = getPrintSize(size);
|
|
|
|
// 文件名
|
|
|
|
String fileName = file.getOriginalFilename(); |
|
|
|
// 后缀名
|
|
|
|