From c85d1d67ffcf657b7d63b3c0d3d6cdd946505339 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期日, 17 三月 2024 17:11:10 +0800
Subject: [PATCH] 整理
---
server/dmvisit_web/src/main/java/com/doumee/api/web/PublicController.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/server/dmvisit_web/src/main/java/com/doumee/api/web/PublicController.java b/server/dmvisit_web/src/main/java/com/doumee/api/web/PublicController.java
index 9d13698..5562a5b 100644
--- a/server/dmvisit_web/src/main/java/com/doumee/api/web/PublicController.java
+++ b/server/dmvisit_web/src/main/java/com/doumee/api/web/PublicController.java
@@ -6,6 +6,7 @@
import com.doumee.core.annotation.trace.Trace;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
+import com.doumee.core.utils.FaceImageCompress;
import com.doumee.core.utils.FtpUtil;
import com.doumee.core.utils.aliyun.ALiYunUtil;
import io.swagger.annotations.Api;
@@ -44,6 +45,15 @@
@Autowired
private SystemDictDataBiz systemDictDataBiz;
+
+ @ApiOperation(value = "鍘嬬缉鍥剧墖", notes = "鍘嬬缉鍥剧墖", httpMethod = "POST", position = 6)
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "folder", value = "鏂囦欢澶�", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class),
+ })
+ @GetMapping(value = "/compressImg")
+ public void compressImg(@RequestParam(name = "folder") String folder, @RequestParam(name = "width") int width, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ FaceImageCompress. compressAllFiles(new File(folder),width);
+ }
@ApiOperation(value = "涓婁紶", notes = "涓婁紶", httpMethod = "POST", position = 6)
@ApiImplicitParams({
@@ -122,7 +132,8 @@
String date = DateUtil.getNowShortDate();
String fName = date+"/"+ UUID.randomUUID()+".jpg";
String fileName = folder+fName;
- boolean r = ftp.uploadInputstream(compressImg(is),fileName);
+// boolean r = ftp.uploadInputstream(compressImg(is),fileName);
+ boolean r = ftp.uploadInputstream(is,fileName);
if(r){
context.put("success", true);
context.put("code", 200);
@@ -161,19 +172,19 @@
int compressedWidth = (int) (originalImage.getWidth() / compressionRatio);
int compressedHeight = (int) (originalImage.getHeight() / compressionRatio);
- BufferedImage compressedImage = new BufferedImage(compressedWidth, compressedHeight, originalImage.getType());
+ BufferedImage compressedImage = new BufferedImage(compressedWidth, compressedHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = compressedImage.createGraphics();
graphics.drawImage(originalImage, 0, 0, compressedWidth, compressedHeight, null);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageOutputStream imOut = ImageIO.createImageOutputStream(byteArrayOutputStream);
- ImageIO.write(compressedImage, "JPEG", imOut);
+ ImageIO.write(compressedImage, "jpg", imOut);
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
graphics.dispose();
return inputStream;
}else{
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageOutputStream imOut = ImageIO.createImageOutputStream(byteArrayOutputStream);
- ImageIO.write(originalImage, "JPEG", imOut);
+ ImageIO.write(originalImage, "jpg", imOut);
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
return inputStream;
}
--
Gitblit v1.9.3