|
@@ -27,8 +27,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import sun.rmi.runtime.Log;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
@@ -58,7 +61,7 @@ public class SceneServiceImpl implements ISceneService {
|
|
|
public FYunFileConfig fYunFileConfig;
|
|
|
|
|
|
@Override
|
|
|
- public ResultData uploadBodySegment(MultipartFile file) throws Exception {
|
|
|
+ public ResultData uploadBodySegment(MultipartFile file, Integer rotate) throws Exception {
|
|
|
|
|
|
if(!FileUtils.checkFileSizeIsLimit(file.getSize(), 10, "M")){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_4003, "10M");
|
|
@@ -68,9 +71,17 @@ public class SceneServiceImpl implements ISceneService {
|
|
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
String extName = fileName.substring(fileName.lastIndexOf("."));
|
|
|
- File tempFile = File.createTempFile(java.util.UUID.randomUUID().toString(), extName);
|
|
|
+ File tempFile = File.createTempFile(uuid, extName);
|
|
|
file.transferTo(tempFile);
|
|
|
|
|
|
+ //判断是否需要旋转
|
|
|
+ if(Objects.nonNull(rotate)){
|
|
|
+ Image rotateImg = ImgUtil.rotate(ImageIO.read(tempFile), rotate);
|
|
|
+ File tempRotateFile = File.createTempFile(uuid + "-rotate", extName);
|
|
|
+ ImgUtil.write(rotateImg, tempRotateFile);
|
|
|
+ tempFile = tempRotateFile;
|
|
|
+ }
|
|
|
+
|
|
|
//校验像素
|
|
|
BufferedImage bufferedImage = ImgUtil.read(tempFile.getPath());
|
|
|
Float scale = 1F;
|
|
@@ -102,6 +113,11 @@ public class SceneServiceImpl implements ISceneService {
|
|
|
return ResultData.ok(uuid);
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+ Image rotateImg = ImgUtil.rotate(ImageIO.read(FileUtil.file("C:\\Users\\dsx\\Desktop\\IMG_6633.HEIC.JPG")), 90);
|
|
|
+ ImgUtil.write(rotateImg, FileUtil.file("C:\\Users\\dsx\\Desktop\\IMG_6633.HEIC_2.JPG"));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void bodySegmentHandler(String imgUrl, String uuid) {
|
|
|
String progress = redisUtil.hget(RedisKey.SCENE_BODY_SEGMENT, uuid);
|