移除极少使用的metadata-extractor图片Meta获取类库,若有需要可自行添加该类库。
This commit is contained in:
@@ -138,12 +138,12 @@
|
|||||||
<version>${UserAgentUtils.version}</version>
|
<version>${UserAgentUtils.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 图片Meta获取 -->
|
<!-- 图片Meta获取
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.drewnoakes</groupId>
|
<groupId>com.drewnoakes</groupId>
|
||||||
<artifactId>metadata-extractor</artifactId>
|
<artifactId>metadata-extractor</artifactId>
|
||||||
<version>${metadata-extractor.version}</version>
|
<version>${metadata-extractor.version}</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
<!-- 缩略图工具 -->
|
<!-- 缩略图工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.coobird</groupId>
|
<groupId>net.coobird</groupId>
|
||||||
|
|||||||
@@ -1,66 +1,66 @@
|
|||||||
/**
|
///**
|
||||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
// * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
*/
|
// */
|
||||||
package com.jeesite.common.image;
|
//package com.jeesite.common.image;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
|
//
|
||||||
import com.drew.imaging.jpeg.JpegMetadataReader;
|
//import com.drew.imaging.jpeg.JpegMetadataReader;
|
||||||
import com.drew.lang.Rational;
|
//import com.drew.lang.Rational;
|
||||||
import com.drew.metadata.Metadata;
|
//import com.drew.metadata.Metadata;
|
||||||
import com.drew.metadata.exif.GpsDirectory;
|
//import com.drew.metadata.exif.GpsDirectory;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 图片地理信息获取
|
// * 图片地理信息获取
|
||||||
* @author ThinkGem
|
// * @author ThinkGem
|
||||||
*/
|
// */
|
||||||
public class ImageGeo {
|
//public class ImageGeo {
|
||||||
|
//
|
||||||
public double lat = 0.0;
|
// public double lat = 0.0;
|
||||||
public double lon = 0.0;
|
// public double lon = 0.0;
|
||||||
public double alt = 0.0;
|
// public double alt = 0.0;
|
||||||
public boolean error = false;
|
// public boolean error = false;
|
||||||
|
//
|
||||||
public ImageGeo(String filename) {
|
// public ImageGeo(String filename) {
|
||||||
try {
|
// try {
|
||||||
error = false;
|
// error = false;
|
||||||
File jpegFile = new File(filename);
|
// File jpegFile = new File(filename);
|
||||||
Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
|
// Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
|
||||||
|
//
|
||||||
GpsDirectory gpsdir = (GpsDirectory) metadata.getDirectoriesOfType(GpsDirectory.class);
|
// GpsDirectory gpsdir = (GpsDirectory) metadata.getDirectoriesOfType(GpsDirectory.class);
|
||||||
Rational latpart[] = gpsdir.getRationalArray(GpsDirectory.TAG_LATITUDE);
|
// Rational latpart[] = gpsdir.getRationalArray(GpsDirectory.TAG_LATITUDE);
|
||||||
Rational lonpart[] = gpsdir.getRationalArray(GpsDirectory.TAG_LONGITUDE);
|
// Rational lonpart[] = gpsdir.getRationalArray(GpsDirectory.TAG_LONGITUDE);
|
||||||
String northing = gpsdir.getString(GpsDirectory.TAG_LATITUDE_REF);
|
// String northing = gpsdir.getString(GpsDirectory.TAG_LATITUDE_REF);
|
||||||
String easting = gpsdir.getString(GpsDirectory.TAG_LONGITUDE_REF);
|
// String easting = gpsdir.getString(GpsDirectory.TAG_LONGITUDE_REF);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
alt = gpsdir.getDouble(GpsDirectory.TAG_ALTITUDE);
|
// alt = gpsdir.getDouble(GpsDirectory.TAG_ALTITUDE);
|
||||||
} catch (Exception ex) {}
|
// } catch (Exception ex) {}
|
||||||
|
//
|
||||||
double latsign = 1.0d;
|
// double latsign = 1.0d;
|
||||||
if (northing.equalsIgnoreCase("S")) {
|
// if (northing.equalsIgnoreCase("S")) {
|
||||||
latsign = -1.0d;
|
// latsign = -1.0d;
|
||||||
}
|
// }
|
||||||
double lonsign = 1.0d;
|
// double lonsign = 1.0d;
|
||||||
if (easting.equalsIgnoreCase("W")) {
|
// if (easting.equalsIgnoreCase("W")) {
|
||||||
lonsign = -1.0d;
|
// lonsign = -1.0d;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
lat = (Math.abs(latpart[0].doubleValue()) + latpart[1].doubleValue() / 60.0d + latpart[2].doubleValue() / 3600.0d) * latsign;
|
// lat = (Math.abs(latpart[0].doubleValue()) + latpart[1].doubleValue() / 60.0d + latpart[2].doubleValue() / 3600.0d) * latsign;
|
||||||
lon = (Math.abs(lonpart[0].doubleValue()) + lonpart[1].doubleValue() / 60.0d + lonpart[2].doubleValue() / 3600.0d) * lonsign;
|
// lon = (Math.abs(lonpart[0].doubleValue()) + lonpart[1].doubleValue() / 60.0d + lonpart[2].doubleValue() / 3600.0d) * lonsign;
|
||||||
|
//
|
||||||
if (Double.isNaN(lat) || Double.isNaN(lon)) {
|
// if (Double.isNaN(lat) || Double.isNaN(lon)) {
|
||||||
error = true;
|
// error = true;
|
||||||
}
|
// }
|
||||||
} catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
error = true;
|
// error = true;
|
||||||
}
|
// }
|
||||||
System.out.println(filename + ": (" + lat + ", " + lon + ")");
|
// System.out.println(filename + ": (" + lat + ", " + lon + ")");
|
||||||
}
|
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
|
||||||
// ImageGeo imageGeo = new ImageGeo(ImageGeo.class.getResource("IMAG0068.jpg").getFile());
|
|
||||||
// System.out.println(imageGeo.lon + "," + imageGeo.lat);
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
}
|
//// public static void main(String[] args) {
|
||||||
|
//// ImageGeo imageGeo = new ImageGeo(ImageGeo.class.getResource("IMAG0068.jpg").getFile());
|
||||||
|
//// System.out.println(imageGeo.lon + "," + imageGeo.lat);
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<commons-email.version>1.5</commons-email.version>
|
<commons-email.version>1.5</commons-email.version>
|
||||||
<activation.version>1.1.1</activation.version>
|
<activation.version>1.1.1</activation.version>
|
||||||
<UserAgentUtils.version>1.21</UserAgentUtils.version>
|
<UserAgentUtils.version>1.21</UserAgentUtils.version>
|
||||||
<metadata-extractor.version>2.11.0</metadata-extractor.version>
|
<!-- <metadata-extractor.version>2.11.0</metadata-extractor.version> -->
|
||||||
<thumbnailator.version>0.4.8</thumbnailator.version>
|
<thumbnailator.version>0.4.8</thumbnailator.version>
|
||||||
<twelvemonkeys.version>3.4.1</twelvemonkeys.version>
|
<twelvemonkeys.version>3.4.1</twelvemonkeys.version>
|
||||||
<blade-patchca.version>1.1.0</blade-patchca.version>
|
<blade-patchca.version>1.1.0</blade-patchca.version>
|
||||||
|
|||||||
Reference in New Issue
Block a user