java 编写客户端 获取图片
发布网友
发布时间:2022-04-26 10:19
我来回答
共1个回答
热心网友
时间:2022-06-27 07:09
package com;
import java.io.File;
import java.util.Iterator;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.imaging.jpeg.JpegProcessingException;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.Tag;
import com.drew.metadata.exif.ExifDirectory;
import com.drew.metadata.exif.GpsDirectory;
import com.drew.metadata.jpeg.JpegDirectory;
public class Test {
public static void main(String[] args){
File jpegFile = new File("F:/图片定位/DCIM/P20130116_125539.jpg");
Metadata metadata;
try {
metadata = JpegMetadataReader.readMetadata(jpegFile);
Directory exif = metadata.getDirectory(ExifDirectory.class);
Iterator tags1 = exif.getTagIterator();
while (tags1.hasNext()) {
Tag tag = (Tag)tags1.next();
System.out.println(tag);
}
Directory jpeg = metadata.getDirectory(JpegDirectory.class);
Iterator tags2 = jpeg.getTagIterator();
while (tags2.hasNext()) {
Tag tag = (Tag)tags2.next();
System.out.println(tag);
}
Directory gps = metadata.getDirectory(GpsDirectory.class);
Iterator tags3 = gps.getTagIterator();
while (tags3.hasNext()) {
Tag tag = (Tag)tags3.next();
System.out.println(tag);
}
} catch (JpegProcessingException e) {
e.printStackTrace();
}
}
}