| | |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |