|
|
@ -130,16 +130,17 @@ public class FileUploadServiceImpl implements IFileUploadService {
|
|
|
|
public void compressFile(String compressPath,String picPath ,Double compressWidth) {
|
|
|
|
public void compressFile(String compressPath,String picPath ,Double compressWidth) {
|
|
|
|
if (Func.isNotBlank(compressPath)) {
|
|
|
|
if (Func.isNotBlank(compressPath)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
File compressFile= new File(compressPath);
|
|
|
|
File compressFile= new File(compressPath);
|
|
|
|
if (!compressFile.getParentFile().exists()) {
|
|
|
|
if (!compressFile.getParentFile().exists()) {
|
|
|
|
compressFile.getParentFile().mkdirs();
|
|
|
|
compressFile.getParentFile().mkdirs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
File compressDest = new File(saveCompressFilePath);
|
|
|
|
File compressDest = new File(compressPath);
|
|
|
|
BufferedImage image = ImageIO.read(new File(picPath));
|
|
|
|
BufferedImage image = ImageIO.read(new File(picPath));
|
|
|
|
int width = image.getWidth();
|
|
|
|
int width = image.getWidth();
|
|
|
|
//图片压缩
|
|
|
|
//图片压缩
|
|
|
|
ImgUtil.scale(image, FileUtil.file(compressDest), (float) (compressWidth / width));
|
|
|
|
ImgUtil.scale(image, FileUtil.file(compressDest), (float) (compressWidth / width));
|
|
|
|
}catch (Exception e){
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -163,6 +164,7 @@ public class FileUploadServiceImpl implements IFileUploadService {
|
|
|
|
//剪切
|
|
|
|
//剪切
|
|
|
|
ImgUtil.cut(image, FileUtil.file(cutDest), new Rectangle(0, startY, width, endY));
|
|
|
|
ImgUtil.cut(image, FileUtil.file(cutDest), new Rectangle(0, startY, width, endY));
|
|
|
|
}catch (Exception e){
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|