1.Metadata-extractor is an open source project for processing image EXIF information, the latest code and:https://github.com/drewnoakes/metadata-extractor
2. The code for this demo project (contains the required jar package): Http://files.cnblogs.com/files/haha12/readPic.rar
The main code is as follows:
Packagecom.test;ImportJava.io.File;Importjava.io.IOException;ImportJava.util.Iterator;ImportCom.drew.imaging.jpeg.JpegMetadataReader;Importcom.drew.imaging.jpeg.JpegProcessingException;Importcom.drew.metadata.Directory;ImportCom.drew.metadata.Metadata;ImportCom.drew.metadata.Tag; Public classReadpic {/*** Import tags, use metadata-extractor * *@paramargs*/ Public Static voidMain (string[] args) {readpic (); } /*** Processing a single picture * *@returnvoid * @date 2015-7-25 pm 7:30:47*/ Private Static voidReadpic () {File jpegfile=NewFile ("D:\\002.jpg"); Metadata Metadata; Try{metadata=Jpegmetadatareader.readmetadata (Jpegfile); Iterator<Directory> it =metadata.getdirectories (). iterator (); while(It.hasnext ()) {Directory exif=It.next (); Iterator<Tag> tags =exif.gettags (). iterator (); while(Tags.hasnext ()) {tag tag=(TAG) tags.next (); SYSTEM.OUT.PRINTLN (tag); } } } Catch(jpegprocessingexception e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); } }}
The console prints the following information:
[Exif IFD0] Software-picasa
[Exif IFD0] Date/time-2015:02:15 12:09:22
[Exif IFD0] Windows XP Keywords-white; blue; color white
[Exif IFD0] Padding-[2060 bytes]
[XMP] XMP Value Count-13
[XMP] Subject-white blue color white
[JFIF] Version-1.1
[JFIF] Resolution Units-inch
[JFIF] X Resolution-96 Dots
[JFIF] Y Resolution-96 Dots
[File] File name-002.jpg
[File] File Size-51798 bytes
[File] File Modified Date-mon Jul 09:55:42 CST 2015
[IPTC] Enveloped Record Version-4
[IPTC] Coded Character Set-utf-8
[IPTC] Application Record Version-4
[IPTC] Keywords-white; blue; color white
[Photoshop] Caption Digest--68-113 27 105-101 114 34-54-56 20 16 108 64 37-42-58
[Exif SUBIFD] Exif Version-2.20
[Exif SUBIFD] Unique Image id-f9b137287bef9686897c8a258ffd089b
[Exif SUBIFD] Padding-[2060 bytes]
[JPEG] Compression Type-baseline
[JPEG] Data Precision-8 Bits
[JPEG] Image Height-870 pixels
[JPEG] Image Width-580 pixels
[JPEG] Number of Components-3
[JPEG] Component 1-y component:quantization table 0, sampling factors 2 horiz/2 vert
[JPEG] Component 2-CB component:quantization Table 1, sampling factors 1 horiz/1 vert
[JPEG] Component 3-CR component:quantization Table 1, sampling factors 1 horiz/1 vert
Java reads EXIF information (size, shooting date, Mark) of the picture