From f984f785528bb3c97e41d483dc214e844993df35 Mon Sep 17 00:00:00 2001 From: fei <791364011@qq.com> Date: 星期四, 28 八月 2025 23:22:16 +0800 Subject: [PATCH] 修改了代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java index 81cfc31..9e13d7e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java @@ -3,10 +3,14 @@ import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; import java.util.List; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; +import com.drew.imaging.ImageMetadataReader; +import com.drew.metadata.Metadata; +import com.drew.metadata.exif.ExifIFD0Directory; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; @@ -15,6 +19,9 @@ import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.service.IDocumentMaterialsService; +import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; +import org.apache.commons.imaging.ImageInfo; +import org.apache.commons.imaging.Imaging; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -156,10 +163,18 @@ int hei = bufferedImage.getHeight(); double sz = Double.parseDouble(String.format("%.2f", file.getSize()*1.0/1024)); System.out.println(wid+":"+hei+":"+sz); + //鎷垮埌鍥惧儚鐨刣pi淇℃伅 + + ImageInfo info = Imaging.getImageInfo(file.getBytes()); + + + int wdpi = info.getPhysicalWidthDpi() ; + int hdpi = info.getPhysicalHeightDpi(); + System.out.println("DPI: " + info.getPhysicalWidthDpi()); //璁$畻fileNumber Long fileNumber = documentMaterialsService.getFiNum(nam); //鎻掑叆鏁版嵁搴撳搴旂殑url褰撲腑 - documentMaterialsService.updateByPageNumber(nam, fileNumber,wid, hei, sz, fileName, pname); + documentMaterialsService.updateByPageNumber(nam, fileNumber,wid, hei,wdpi, hdpi, sz, fileName, pname); // System.out.println(url); // System.out.println(fileName); ajax.put("fileName", fileName); -- Gitblit v1.9.1