From 2db1aa88e8ab53096a936163d686b90d8e056a99 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 21 Aug 2024 23:18:33 +0800
Subject: [PATCH] 国土对接返回信息加密

---
 src/main/java/com/dji/sample/media/util/ImgUtil.java |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/dji/sample/media/util/ImgUtil.java b/src/main/java/com/dji/sample/media/util/ImgUtil.java
index e58c2e9..f7b9a6f 100644
--- a/src/main/java/com/dji/sample/media/util/ImgUtil.java
+++ b/src/main/java/com/dji/sample/media/util/ImgUtil.java
@@ -91,7 +91,16 @@
             return null;
         }
     }
+    /**
+     * 获取图片的XMP信息
+     *
+     * @param file 图片文件
+     * @return 包含图片XMP信息的JSONObject对象
+     * @throws ImageProcessingException 图像处理异常
+     * @throws IOException 输入输出异常
+     */
     public static Object getInfo(File file) throws ImageProcessingException, IOException {
+        // 从文件中提取XMP信息
         String str =getXmp(file);
         // 解析 JSON 字符串为 JSON 对象
         JSONObject jsonObject = JSON.parseObject(str);
@@ -101,20 +110,19 @@
         String flightYawDegree = jsonObject.getString("drone-dji:FlightYawDegree");
         String flightPitchDegree = jsonObject.getString("drone-dji:FlightPitchDegree");
         String gimbalPitchDegree = jsonObject.getString("drone-dji:GimbalPitchDegree");
+        // 读取图片的XMP信息中的焦距
         String mm=readPicExifInfo(file).get("Focal Length 35");
         // 构造新的 JSON 对象
         JSONObject newJsonObject = new JSONObject();
+        // 将获取到的信息添加到新的 JSON 对象中
         newJsonObject.put("GimbalYawDegree", gimbalYawDegree);
         newJsonObject.put("FlightYawDegree", flightYawDegree);
         newJsonObject.put("FlightPitchDegree", flightPitchDegree);
         newJsonObject.put("GimbalPitchDegree", gimbalPitchDegree);
         newJsonObject.put("FocalLength", mm);
+        // 返回包含图片XMP信息的JSON对象
         return newJsonObject;
     }
 
-    public static void main(String[] args) throws ImageProcessingException, IOException {
-        File file1 = TbFjServiceImpl.downloadFile("http://dev.jxpskj.com:9000/cloud-bucket/05708dc5-4273-4b12-ad54-e05c89d6c3d4/DJI_202406031131_010_05708dc5-4273-4b12-ad54-e05c89d6c3d4/DJI_20240603113305_0001_W_航点1.jpeg");
-        System.out.println(getInfo(file1));
-    }
 
 }

--
Gitblit v1.9.3