|
@@ -20,6 +20,7 @@ import cn.reghao.oss.store.util.FileType;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import javax.imageio.IIOException;
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -101,24 +102,29 @@ public class MediaFileProcessor {
|
|
|
* @date 2025-08-17 00:08:482
|
|
* @date 2025-08-17 00:08:482
|
|
|
*/
|
|
*/
|
|
|
public ImageInfo getImageInfo(String imageFileId) throws Exception {
|
|
public ImageInfo getImageInfo(String imageFileId) throws Exception {
|
|
|
- ObjectMeta objectMeta = objectRepository.getObjectMetaById(imageFileId);
|
|
|
|
|
- if (objectMeta == null) {
|
|
|
|
|
- String errMsg = String.format("%s not exist in oss-store", imageFileId);
|
|
|
|
|
- throw new Exception(errMsg);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ObjectMeta objectMeta = objectRepository.getObjectMetaById(imageFileId);
|
|
|
|
|
+ if (objectMeta == null) {
|
|
|
|
|
+ String errMsg = String.format("%s not exist in oss-store", imageFileId);
|
|
|
|
|
+ throw new Exception(errMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String absolutePath = objectMeta.getAbsolutePath();
|
|
|
|
|
+ File file = new File(absolutePath);
|
|
|
|
|
+ String format = ImageOps.getFormat(file);
|
|
|
|
|
+ ImageOps.Size size = ImageOps.info(new File(absolutePath));
|
|
|
|
|
+ int width = size.getWidth();
|
|
|
|
|
+ int height = size.getHeight();
|
|
|
|
|
+ String objectId = imageFileId;
|
|
|
|
|
+ String objectName = objectMeta.getObjectName();
|
|
|
|
|
+ long size1 = objectMeta.getSize();
|
|
|
|
|
+
|
|
|
|
|
+ ImageInfo imageInfo = new ImageInfo(imageFileId, objectId, format, objectName, width, height, size1);
|
|
|
|
|
+ return imageInfo;
|
|
|
|
|
+ } catch (IIOException iioException) {
|
|
|
|
|
+ String msg = iioException.getMessage();
|
|
|
|
|
+ throw new Exception(msg);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- String absolutePath = objectMeta.getAbsolutePath();
|
|
|
|
|
- File file = new File(absolutePath);
|
|
|
|
|
- String format = ImageOps.getFormat(file);
|
|
|
|
|
- ImageOps.Size size = ImageOps.info(new File(absolutePath));
|
|
|
|
|
- int width = size.getWidth();
|
|
|
|
|
- int height = size.getHeight();
|
|
|
|
|
- String objectId = imageFileId;
|
|
|
|
|
- String objectName = objectMeta.getObjectName();
|
|
|
|
|
- long size1 = objectMeta.getSize();
|
|
|
|
|
-
|
|
|
|
|
- ImageInfo imageInfo = new ImageInfo(imageFileId, objectId, format, objectName, width, height, size1);
|
|
|
|
|
- return imageInfo;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<ConvertedImageInfo> getWebpInfos(List<String> imageFileIds) {
|
|
public List<ConvertedImageInfo> getWebpInfos(List<String> imageFileIds) {
|