日期:2014-05-20  浏览次数:20832 次

利用JAVA将经纬度写入EXIF中
请问有人有做过吗
如果能的话请告诉我怎么做
或者是提供参考数据


------解决方案--------------------
LZ可以使用下这个jar
http://www.drewnoakes.com/code/exif/metadata-extractor-2.1.jar
也有源代码
http://www.drewnoakes.com/code/exif/metadata-extractor-src-2.1.jar

然后
import com.drew.metadata.*;
import com.drew.metadata.exif.*;
import com.drew.imaging.jpeg.JpegProcessingException;
import java.io.*;
import java.util.Iterator;

public class EXIFReader {

public static void main(String args[]) {
File f = new File("c:\\b.jpg");
try {
ExifReader er = new ExifReader(f);
Metadata exif = er.extract();
Iterator itr = exif.getDirectoryIterator();
while(itr.hasNext()) {
Directory directory = (Directory)itr.next();
/*
System.out.println("EXIF版本 " + directory.getString(ExifDirectory.TAG_EXIF_VERSION));
System.out.println("相机品牌 " + directory.getString(ExifDirectory.TAG_MAKE));
System.out.println("相机型号 " + directory.getString(ExifDirectory.TAG_MODEL));
System.out.println("光圈 " + directory.getString(ExifDirectory.TAG_FNUMBER));
System.out.println("快門 " + directory.getString(ExifDirectory.TAG_EXPOSURE_TIME));
System.out.println("感光度 " + directory.getString(ExifDirectory.TAG_ISO_EQUIVALENT));
break;*/

//获得全部metadata
Iterator tags = directory.getTagIterator();
while (tags.hasNext()) {
Tag tag = (Tag)tags.next();
System.out.println(tag);
}
if (directory.hasErrors()) {
Iterator errors = directory.getErrors();
while (errors.hasNext()) {
System.out.println("ERROR: " + errors.next());
}
}
}
} catch (JpegProcessingException e) {
System.err.println("not jpeg file");
} catch (FileNotFoundException ex) {
System.err.println("file not found");
}

}

}