jpg图片的Exif及gps信息和示例分析

转自:http://www.verydemo.com/demo_c173_i10439.html

jpg图片的Exif及gps信息和示例分析

jpg 图片的Exif及gps 信息
    拍照时gps相关 信息写到EXIF块中。
    在exif2.1就有gps的 信息块。参见《Exif2-2.PDF》
    Exif是英文Exchangeable Image File(可交换图像文件)的缩写,
    最初由日本电子工业发展协会(JEIDA --Japan Electronic Industry Development Association) 制订,目前的最新版本是2.21 版。
    国际标准化组织(ISO)正在制订的相机文件设计标准(DCF -- Design role for Camera File system)可能以Exif2.1为基础。
    Exif 文件实际是JPEG文件的一种,遵从JPEG标准,只是在文件头 信息中增加了有关拍摄 信息的内容和索引图。所以你可以使用任何
    支持JPEG格式的图像工具软件观看或修改Exif文件,但,打开时可能看不到Exif 信息,一旦修改,Exif 信息可能丢失。
    简单来说,EXIF  信息就是由数码相机在拍摄过程中采集一系列的 信息,然后把 信息放置在我们熟知的 JPEG/TIFF 文件的头部,
    也就是说 EXIF  信息是镶嵌在 JPEG/TIFF 图像文件格式内的一组拍摄参数,主要包括摄影时的光圈、快门、ISO、日期时间等各种
    与当时摄影条件相关的讯息,相机品牌型号,色彩编码,拍摄时录制的声音以及全球定位系统(GPS)等 信息
    简单的说,它就好像是傻瓜相机的日期打印功能一样,只不过 EXIF  信息所记录的资讯更为详尽和完备。    


  Exif的标识:所有的JPEG文件以字符串“0xFFD8”开头,并以字符串“0xFFD9”结束。文件头中有一系列“0xFF??”格式的字符串,称为“标识”,
    用来标记JPEG文件的 信息段。“0xFFD8”表示图像 信息开始,“0xFFD9”表示图像 信息结束,这两个标识后面没有 信息,而其它标识紧跟一些 信息字符。
    0xFFE0 -- 0xFFEF之间的标识符称为“应用标记”,没有被常规JPEG文件利用,Exif正是利用这些 信息串记录拍摄 信息如快门速度、光圈值等,
    甚至可以包括全球定位 信息。按照Exif2.1标准对这些标识符的定义,数码相机可以把各种拍摄 信息记入数码图像中,应用软件可以读取这些数据,
    再按照Exif2.1标准,检索出它们的具体含义。


    GPS,Global Positioning System(全球卫星定位系统),是美国从20世纪70年代开始耗巨资研制,于1994年全面建成,具有在海、陆、空进行全方位
    实时三维导航与定位能力的新一代卫星导航与定位系统。
    越来越多的数码相机厂商也开始在他们的新产品里提供了GPS功能的支持,(如Kodak DCS760等)可将照片拍摄瞬间所处经度、纬度、海拔的三维空间
    定位数据记载在 图片里,只要 图片里保留了完整的 GPS  信息,IExif 就能准确地再现给查看者。        


   jpg整个文件的大体结构,由标记块组成,一般标记块由标记码(2字节)+长度(2字节)+数据(长度n),只有SOI和EOI没有长度和数据。长度为大端数据。
   标记码由两个字节构成,其前一个字节是固定值0xFF,后一个字节则根据不同意义有不同数值。
   JFIF格式的JPEG文件(*.jpg)的一般顺序为:
    SOI(0xFFD8)            Start of Image,图像开始
    APP0(0xFFE0)         Application,应用程序0
    [APPn(0xFFEn)]可选   Application,应用程序n
    DQT(0xFFDB)          Define Quantization Table,定义量化表
    SOF0(0xFFC0)         Start of Frame,帧图像开始
    DHT(0xFFC4)           Difine Huffman Table,定义哈夫曼表
    SOS(0xFFDA)          Start of Scan,扫描开始 12字节
    压缩数据
    EOI(0xFFD9)            End of Image,图像结束 2字节
 
    (0xFF后的0xD0~0xD7,则组成RSTn标记)


   Exif格式的JPEG文件(*.jpg)的一般顺序为:
    SOI(0xFFD8)          Start of Image,图像开始
    APP1(0xFFE1)         Application,应用程序1   
    DQT(0xFFDB)          Define Quantization Table,定义量化表
    DHT(0xFFC4)          Difine Huffman Table,定义哈夫曼表
    SOF0(0xFFC0)         Start of Frame,帧图像开始
    SOS(0xFFDA)          Start of Scan,扫描开始 12字节
    压缩数据
    EOI(0xFFD9)          End of Image,图像结束 2字节

下面的内容是从Exif2-2.pdf上拷贝下来的:

   APP1的组成:  
    APP1 Marker          FF E1
    Length                      3A 59
    Exif Identifier Code Exif
    TIFF Header            MM 002A 00000008
    0th IFD
    ...
    Exif IFD
    1st IFD
    JPEGInterchangeFormat
    JPEGInterchangeFormatLength
    JPEG Thumbnail

 TIFF Header

    Name       Size (Bytes) Value
    Byte Order 2            either "II" (4949.H) (little endian) or "MM" (4D4D.H)(big endian)
     42        2            002A.H (fixed)    
    Offset IFD 4            0th IFD offset. If the TIFF header is followed immediately by the 0th IFD, it is written as 00000008.H.  
  JPEG Thumbnail组成:(Compressed Thumbnail)
    SOI
    DQT
    DHT
    SOF
    SOS
    Compressed Data
    EOI


    (0xFF后的0xD0~0xD7,则组成RSTn标记)
    
    采用了TIFF VER 6.0的文件头相关 信息。下面是Exif2-2的简要 信息
    File Header,
    0th IFD,
    0th IFD Value,
    1st IFD,
    1st IFD Value,
    1st (Thumbnail) Image Data,
    0th (Primary) Image Data.    


  IFD:
    2bytes  number of fields
    12bytes Tag:
      Bytes 0-1 Tag
      Bytes 2-3 Type
      Bytes 4-7 Count              The number of values, NOT bytes, such as SHORT,COUNT=1 is 2bytes
      Bytes 8-11 Value or Offset   This tag records the offset from the start of the TIFF header In cases where the value fits in 4 bytes, the value itself is recorded
    4bytes  nextIFD
    
    TYPE:
    1 = BYTE An 8-bit unsigned integer.,
    2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.,
    3 = SHORT A 16-bit (2-byte) unsigned integer,
    4 = LONG A 32-bit (4-byte) unsigned integer,
    5 = RATIONAL Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator.,
    7 = UNDEFINED An 8-bit byte that can take any value depending on the field definition,
    9 = SLONG A 32-bit (4-byte) signed integer (2's complement notation),
    10 = SRATIONAL Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator.
    
    Exif IFD: Exif IFD is a set of tags for recording Exif-specific attribute information
    Exif IFD Pointer
    Tag = 34665 (8769.H)
    Type = LONG
    Count = 1
    Default = none  
    
    GPS IFD:GPS IFD is a set of tags for recording GPS information  
    GPS Info IFD Pointer
    Tag = 34853 (8825.H)    2bytes
    Type = LONG  0004       2bytes
    Count = 1   00000001    4bytes
    Default = none          4bytes 例:000002A2
    
    Interoperability IFD:Interoperability IFD is composed of tags which stores the information to ensure the Interoperability and pointed by
                         the following tag located in Exif IFD
    Interoperability IFD Pointer
    Tag = 40965 (A005.H)
    Type = LONG
    Count = 1
    Default = None  


    TIFF Rev. 6.0 Attribute Information
                                                                                          Tag ID
    Tag Name                    Field Name                           Dec Hex    Type                       Count        
A. Tags relating to image data structure
   Image width                  ImageWidth                            256 100 SHORT or LONG     1
   Image height                 ImageLength                          257 101 SHORT or LONG     1
   Number of bits per component BitsPerSample        258 102 SHORT                      3
   Compression scheme           Compression               259 103 SHORT                      1
   Pixel composition            PhotometricInterpretation 262 106 SHORT                       1
   Orientation of image         Orientation                        274 112 SHORT                       1
   Number of components         SamplesPerPixel        277 115 SHORT                       1
   Image data arrangement       PlanarConfiguration    284 11C SHORT                     1
   Subsampling ratio of Y to C  YCbCrSubSampling    530 212 SHORT                      2
   Y and C positioning          YCbCrPositioning             531 213 SHORT                      1
   Image resolution in width    XResolution                    282 11A RATIONAL                 1
   Image resolution in height   YResolution                    283 11B RATIONAL                 1
   Unit of X and Y resolution   ResolutionUnit                296 128 SHORT                       1
B. Tags relating to recording offset
   Image data location          StripOffsets                       273 111 SHORT or LONG    *S
   Number of rows per strip     RowsPerStrip                278 116 SHORT or LONG     1
   Bytes per compressed strip   StripByteCounts         279 117 SHORT or LONG    *S
   Offset to JPEG SOI           JPEGInterchangeFormat  513 201 LONG                       1
   Bytes of JPEG data         JPEGInterchangeFormatLength 514 202 LONG              1
C. Tags relating to image data characteristics
   Transfer function            TransferFunction                  301 12D SHORT            3 * 256
   White point chromaticity     WhitePoint                      318 13E RATIONAL                2
   Chromaticities of primaries  PrimaryChromaticities 319 13F RATIONAL               6
   Color transf matrix coef     YCbCrCoefficients          529 211 RATIONAL                3
   Pair of black and white refl ReferenceBlackWhite    532 214 RATIONAL               6
D. Other tags
   File change date and time    DateTime                     306 132 ASCII                       20
   Image title                  ImageDescription                     270 10E ASCII           Any
   Image input equipment manuf  Make                         271 10F ASCII           Any
   Image input equipment model  Model                        272 110 ASCII           Any
   Software used                Software                              305 131 ASCII           Any
   Person who created the image Artist                        315 13B ASCII           Any
   Copyright holder             Copyright                      33432 8298 ASCII          Any    


*S Chunky format: StripsPerImage
   Planar format: SamplesPerImage * StripsPerImage
   StripsPerImage = floor((ImageLength + RowsPerStrip -1)/ RowsPerStrip)


   
   Exif IFD Attribute Information
                                                                                                       Tag ID
    Tag Name                    Field Name                                         Dec   Hex  Type                     Count        
A. Tags Relating to Version
    Exif version                ExifVersion                                           36864 9000 UNDEFINED      4
    Supported Flashpix version  FlashpixVersion                      40960 A000 UNDEFINED      4
B. Tag Relating to Image Data Characteristics
    Color space information     ColorSpace                                40961 A001 SHORT                1
C. Tags Relating to Image Configuration
    Meaning of each component   ComponentsConfiguration   37121 9101 UNDEFINED      4
    Image compression mode      CompressedBitsPerPixel    37122 9102 RATIONAL           1
    Valid image width           PixelXDimension                           40962 A002 SHORT or LONG  1
    Valid image height          PixelYDimension                           40963 A003 SHORT or LONG  1
D. Tags Relating to User Information
    Manufacturer notes          MakerNote                                     37500 927C UNDEFINED    Any
    User comments               UserComment                                37510 9286 UNDEFINED    Any
E. Tag Relating to Related File Information
    Related audio file          RelatedSoundFile                            40964 A004 ASCII         13
F. Tags Relating to Date and Time
    Date time of orig data gen  DateTimeOriginal                      36867 9003 ASCII         20
    Date time of digi data gen  DateTimeDigitized                    36868 9004 ASCII         20
    DateTime subseconds         SubSecTime                              37520 9290 ASCII        Any
    DateTimeOriginal subseconds SubSecTimeOriginal          37521 9291 ASCII        Any
    DateTimeDigitized subseconds SubSecTimeDigitized      37522 9292 ASCII        Any
G. Tags Relating to Picture-Taking Conditions
See Table 5
H. Other Tags
    Unique image ID             ImageUniqueID                               42016 A420 ASCII         33


G. Tags Relating to Picture-Taking Conditions
    Exposure time               ExposureTime                                 33434 829A RATIONAL       1
    F number                    FNumber                                             33437 829D RATIONAL       1
    Exposure program            ExposureProgram                      34850 8822 SHORT          1
    Spectral sensitivity        SpectralSensitivity                         34852 8824 ASCII        Any
    ISO speed rating            ISOSpeedRatings                         34855 8827 SHORT        Any
    Optoelectric conv factor    OECF                                         34856 8828 UNDEFINED    Any
    Shutter speed               ShutterSpeedValue                        37377 9201 SRATIONAL      1
    Aperture                    ApertureValue                                     37378 9202 RATIONAL       1
    Brightness                  BrightnessValue                               37379 9203 SRATIONAL      1
    Exposure bias               ExposureBiasValue                      37380 9204 SRATIONAL      1
    Maximum lens aperture       MaxApertureValue                  37381 9205 RATIONAL       1
    Subject distance            SubjectDistance                            37382 9206 RATIONAL       1
    Metering mode               MeteringMode                              37383 9207 SHORT          1
    Light source                LightSource                                      37384 9208 SHORT          1
    Flash                       Flash                                                      37385 9209 SHORT          1
    Lens focal length           FocalLength                                   37386 920A RATIONAL       1
    Subject area                SubjectArea                                     37396 9214 SHORT      2 or 3 or 4
    Flash energy                FlashEnergy                                    41483 A20B RATIONAL       1
    Spatial frequency response  SpatialFrequencyResponse  41484 A20C UNDEFINED    Any
    Focal plane X resolution    FocalPlaneXResolution          41486 A20E RATIONAL       1
    Focal plane Y resolution    FocalPlaneYResolution           41487 A20F RATIONAL       1
    Focal plane resolution unit FocalPlaneResolutionUnit      41488 A210 SHORT          1
    Subject location            SubjectLocation                             41492 A214 SHORT          2
    Exposure index              ExposureIndex                              41493 A215 RATIONAL       1
    Sensing method              SensingMethod                           41495 A217 SHORT          1
    File source                 FileSource                                         41728 A300 UNDEFINED      1
    Scene type                  SceneType                                       41729 A301 UNDEFINED      1
    CFA pattern                 CFAPattern                                     41730 A302 UNDEFINED    Any
    Custom image processing     CustomRendered              41985 A401 SHORT          1
    Exposure mode               ExposureMode                          41986 A402 SHORT          1
    White balance               WhiteBalance                               41987 A403 SHORT          1
    Digital zoom ratio          DigitalZoomRatio                         41988 A404 RATIONAL       1
    Focal length in 35 mm film  FocalLengthIn35mmFilm     41989 A405 SHORT          1
    Scene capture type          SceneCaptureType                 41990 A406 SHORT          1
    Gain control                GainControl                                     41991 A407 RATIONAL       1
    Contrast                    Contrast                                             41992 A408 SHORT          1
    Saturation                  Saturation                                         41993 A409 SHORT          1
    Sharpness                   Sharpness                                      41994 A40A SHORT          1
    Device settings description DeviceSettingDescription  41995 A40B UNDEFINED    Any
    Subject distance range      SubjectDistanceRange         41996 A40C SHORT          1
 
GPS Attribute Information
                                                                                               Tag ID
    Tag Name                    Field Name                              Dec   Hex  Type           Count        
A. Tags Relating to GPS
   GPS tag version              GPSVersionID                      0     0    BYTE                4
   North or South Latitude      GPSLatitudeRef                1     1    ASCII                2
   Latitude                     GPSLatitude                                 2     2    RATIONAL       3
   East or West Longitude       GPSLongitudeRef           3     3    ASCII                2
   Longitude                    GPSLongitude                           4     4    RATIONAL       3
   Altitude reference           GPSAltitudeRef                     5     5    BYTE                1
   Altitude                     GPSAltitude                                   6     6    RATIONAL       1
   GPS time (atomic clock)      GPSTimeStamp              7     7    RATIONAL       3
   GPS satellites used          GPSSatellites                      8     8    ASCII            Any
   GPS receiver status          GPSStatus                          9     9    ASCII                 2
   GPS measurement mode         GPSMeasureMode   10    A    ASCII                2
   Measurement precision        GPSDOP                        11    B    RATIONAL       1
   Speed unit                   GPSSpeedRef                          12    C    ASCII                2
   Speed of GPS receiver        GPSSpeed                      13    D    RATIONAL       1
   Reference dir of movement    GPSTrackRef               14    E    ASCII                 2
   Direction of movement        GPSTrack                         15    F    RATIONAL       1
   Reference direction of image GPSImgDirectionRef   16   10    ASCII                2
   Direction of image           GPSImgDirection                 17   11    RATIONAL       1
   Geodetic survey data used    GPSMapDatum             18   12    ASCII            Any
   Reference latitude of dest   GPSDestLatitudeRef       19   13    ASCII                2
   Latitude of destination      GPSDestLatitude                20   14    RATIONAL       3
   Reference longitude of dest  GPSDestLongitudeRef  21   15    ASCII                2
   Longitude of destination     GPSDestLongitude           22   16    RATIONAL       3
   Reference bearing of dest    GPSDestBearingRef      23   17    ASCII                2
   Bearing of destination       GPSDestBearing                24   18    RATIONAL       1
   Reference distance to dest   GPSDestDistanceRef    25   19    ASCII                2
   Distance to destination      GPSDestDistance              26   1A    RATIONAL       1
   Name GPS process method GPSProcessingMethod 27   1B    UNDEFINED    Any
   Name of GPS area             GPSAreaInformation          28   1C    UNDEFINED    Any
   GPS date                     GPSDateStamp                         29   1D    ASCII              11
   GPS differential correction  GPSDifferential                30   1E    SHORT              1


如何 分析一个Exif的jpg文件中的gps 信息
   实例 分析:PICT0021.JPG
00   FF D8 FF E1 3A 59 45 78 69 66 00 00 4D 4D 00 2A 
10   00 00 00 08 00 0C 01 0E 00 02 00 00 00 0E 00 00
20   03 F4 01 0F 00 02 00 00 00 20 00 00 04 02 01 10
30   00 02 00 00 00 20 00 00 04 22 01 12 00 03 00 00
40   00 01 00 01 00 00 01 1A 00 05 00 00 00 01 00 00
50   04 42 01 1B 00 05 00 00 00 01 00 00 04 4A 01 28
60   00 03 00 00 00 01 00 02 00 00 01 31 00 02 00 00 
70   00 20 00 00 04 52 01 32 00 02 00 00 00 14 00 00
80   04 72 02 13 00 03 00 00 00 01 00 01 00 00 87 69
90   00 04 00 00 00 01 00 00 00 9E 88 25 00 04 00 00
A0   00 01 00 00 02 A2 00 00 02 E4 00 28 82 9A 00 05
B0   00 00 00 01 00 00 04 86 82 9D 00 05 00 00 00 01
C0   00 00 04 8E 88 22 00 03 00 00 00 01 00 02 00 00
D0   88 27 00 03 00 00 00 01 00 C8 00 00 90 00 00 07
E0   00 00 00 04 30 32 32 31 90 03 00 02 00 00 00 14
F0   00 00 04 96 90 04 00 02 00 00 00 14 00 00 04 AA
100  91 01 00 07 00 00 00 04 01 02 03 00 91 02 00 05
110  00 00 00 01 00 00 04 BE 92 01 00 0A 00 00 00 01
120  00 00 04 C6 92 02 00 05 00 00 00 01 00 00 04 CE
130  92 04 00 0A 00 00 00 01 00 00 04 D6 92 05 00 05
140  00 00 00 01 00 00 04 DE 92 06 00 05 00 00 00 01
150  00 00 04 E6 92 07 00 03 00 00 00 01 00 02 00 00
160  92 08 00 03 00 00 00 01 00 00 00 00 92 09 00 03
170  00 00 00 01 00 20 00 00 92 0A 00 05 00 00 00 01
180  00 00 04 EE 92 7C 00 07 00 00 00 40 00 00 04 F6
190  A0 00 00 07 00 00 00 04 30 31 30 30 A0 01 00 03
1A0  00 00 00 01 00 01 00 00 A0 02 00 04 00 00 00 01
1B0  00 00 12 00 A0 03 00 04 00 00 00 01 00 00 0D 80
1C0  A0 05 00 04 00 00 00 01 00 00 02 84 A2 15 00 05
1D0  00 00 00 01 00 00 05 36 A2 17 00 03 00 00 00 01
1E0  00 02 00 00 A3 00 00 07 00 00 00 01 03 00 00 00
1F0  A3 01 00 07 00 00 00 01 01 00 00 00 A4 01 00 03
200  00 00 00 01 00 00 00 00 A4 02 00 03 00 00 00 01
210  00 00 00 00 A4 03 00 03 00 00 00 01 00 00 00 00
220  A4 04 00 05 00 00 00 01 00 00 05 3E A4 05 00 03
230  00 00 00 01 00 29 00 00 A4 06 00 03 00 00 00 01
240  00 00 00 00 A4 07 00 03 00 00 00 01 00 00 00 00
250  A4 08 00 03 00 00 00 01 00 00 00 00 A4 09 00 03
260  00 00 00 01 00 00 00 00 A4 0A 00 03 00 00 00 01
270  00 00 00 00 A4 0B 00 07 00 00 00 04 00 00 00 00
280  A4 0C 00 03 00 00 00 01 00 00 00 00 00 00 00 00
290  00 02 00 01 00 02 00 00 00 04 52 39 38 00 00 02
2A0  00 07 00 00 00 04 30 31 30 30 00 00 00 00 00 05
2B0  00 00 00 01 00 00 00 04 02 02 00 00 00 01 00 02
2C0  00 00 00 02 4E 00 00 00 00 02 00 05 00 00 00 03
2D0  00 00 05 46 00 03 00 02 00 00 00 02 45 00 00 00
2E0  00 04 00 05 00 00 00 03 00 00 05 5E 00 00 00 00
2F0  00 06 01 03 00 03 00 00 00 01 00 06 00 00 01 1A
300  00 05 00 00 00 01 00 00 05 76 01 1B 00 05 00 00
310  00 01 00 00 05 7E 01 28 00 03 00 00 00 01 00 02
320  00 00 02 01 00 04 00 00 00 01 00 00 07 F4 02 02
330  00 04 00 00 00 01 00 00 32 5D 00 00 00 00 00 00
   
   FF D8       SOI
   FF E1       APP1
   3A 59       APP1 LENGTH
   45 78 69 66 00 00 Exif ASCII结束符两个
   4D 4D       MM big endian TIFF Header (注意小端的为:49492A00 08000000)
   00 2A       fixed
   00 00 00 08 IFD0 offset
   00 0C       IFD0: number of TAGs 12个tag,每个12字节。
   01 0E       TAG      Image title   
   00 02       TYPE ASCII
   00 00 00 0E count   最多13个字符
   00 00 03 F4 offset +0C=0x400 可以看到DCIM\100MEDIA (0x0c from the start of the TIFF header 4D4D MM)


   01 0F       TAG Image input equipment manuf 
   00 02       TYPE ASCII
   00 00 00 20 count   最多31个字符
   00 00 04 02 offset +0c=0x040E 可以看到TCL


   01 10       TAG Image input equipment model 
   00 02       TYPE ASCII
   00 00 00 20 count
   00 00 04 22 offset +0c=0x042E 可以看到SDV05
   
   01 12       TAG Orientation of image 
   00 03       SHORT             00 01
   00 00 00 01 count
   00 01 00 00 value 
   
   01 1A       TAG Image resolution in width 0x0442+0c=0x44E,可以看到00 00 00 48/00 00 00 01
   00 05       RATIONAL 
   00 00 00 01 count
   00 00 04 42 offset +0c=0x44E,可以看到00 00 00 48/00 00 00 01
   
   01 1B       TAG Image resolution in height 
   00 05       RATIONAL
   00 00 00 01 
   00 00 04 4A offset+0c=0x456 可以看到00 00 00 48/00 00 00 01
   
   01 28       Unit of X and Y resolution
   00 03       SHORT                00 02
   00 00 00 01 
   00 02 00 00 
   
   01 31       Software used 
   00 02       ASCII
   00 00 00 20 count
   00 00 04 52 offset +0c =0x45E 可以看到0.0.2
   
   01 32       DateTime 
   00 02       ASCII
   00 00 00 14 20字节
   00 00 04 72 offset+0c=0x47E,可以看到2012:07:29 21:28:18
   
   02 13       YCbCrPositioning
   00 03       SHORT      00 01
   00 00 00 01 
   00 01 00 00
   
   87 69       Exif IFD Pointer
   00 04       LONG
   00 00 00 01 count
   00 00 00 9E offset+0c=0xAA
   
   88 25       GPS Info IFD Pointer
   00 04       LONG
   00 00 00 01 count
   00 00 02 A2 offset+0c=0x02AE
   
   00 00 02 E4 nextIFD IFD1 offset
   
   00 28  Exif IFD number of TAGs
   82 9A  ExposureTime
   00 05  RATIONAL
   00 00 00 01 count
   00 00 04 86 offset+0c=0x0492
   ...

   Exif的相关信息这里先不做分析,请大家参照上面的文档自己分析了。

   

   这里主要是分析GPS相关信息

   GPS Info IFD Pointer 0x02AE  从上面数据2A0行的后面看数据
   00 05       count of TAGs
   
   00 00       GPSVersionID
   00 01       BYTE
   00 00 00 04 count
   02 02 00 00 value 2.2.0.0
   
   00 01       GPSLatitudeRef
   00 02       ASCII
   00 00 00 02 count
   4E 00 00 00 N North  
   
   00 02       GPSLatitude
   00 05       RATIONAL               前4字节为分子,后4字节为分母,十六进制先转为十进制
   00 00 00 03 count
   00 00 05 46 offset+0c=0x552 16 00 00 00 01 00 00 00 22 00 00 00 01 00 00 00 51 00 00 00 04 00 00 00
                                                       22/1=22                             34/1=34                              81/4= 20.25
                                                      通过windows的右键属性看详细 信息:22;34;20.249999999999915
   00 03       GPSLongitudeRef
   00 02
   00 00 00 02 count
   45 00 00 00 East
   
   00 04       GPSLongitude
   00 05       RATIONAL
   00 00 00 03 count
   00 00 05 5E offset+0c=0x56A 71 00 00 00 01 00 00 00 37 00 00 00 01 00 00 00 6C 00 00 00 04 00
                                                       113/1=113                          55/1=55                             108/4=27
                                                    通过windows的右键属性看详细 信息:113;55;27.000000000000171

550 04 00 16 00 00 00 01 00 00 00 22 00 00 00 01 00 
560 00 00 51 00 00 00 04 00 00 00 71 00 00 00 01 00
570 00 00 37 00 00 00 01 00 00 00 6C 00 00 00 04 00
580 00 00 00 00 00 48 00 00 00 01 00 00 00 48 00 00
590 00 01 00 00 00 00 00 00
   主要 分析gps相关 信息
   对于Exif的相关 信息可以参照tag进行 分析

jpg 图片的Exif及gps 信息
    拍照时gps相关 信息写到EXIF块中。
    在exif2.1就有gps的 信息块。参见《Exif2-2.PDF》
    Exif是英文Exchangeable Image File(可交换图像文件)的缩写,
    最初由日本电子工业发展协会(JEIDA --Japan Electronic Industry Development Association) 制订,目前的最新版本是2.21 版。
    国际标准化组织(ISO)正在制订的相机文件设计标准(DCF -- Design role for Camera File system)可能以Exif2.1为基础。
    Exif 文件实际是JPEG文件的一种,遵从JPEG标准,只是在文件头 信息中增加了有关拍摄 信息的内容和索引图。所以你可以使用任何
    支持JPEG格式的图像工具软件观看或修改Exif文件,但,打开时可能看不到Exif 信息,一旦修改,Exif 信息可能丢失。
    简单来说,EXIF  信息就是由数码相机在拍摄过程中采集一系列的 信息,然后把 信息放置在我们熟知的 JPEG/TIFF 文件的头部,
    也就是说 EXIF  信息是镶嵌在 JPEG/TIFF 图像文件格式内的一组拍摄参数,主要包括摄影时的光圈、快门、ISO、日期时间等各种
    与当时摄影条件相关的讯息,相机品牌型号,色彩编码,拍摄时录制的声音以及全球定位系统(GPS)等 信息
    简单的说,它就好像是傻瓜相机的日期打印功能一样,只不过 EXIF  信息所记录的资讯更为详尽和完备。    


  Exif的标识:所有的JPEG文件以字符串“0xFFD8”开头,并以字符串“0xFFD9”结束。文件头中有一系列“0xFF??”格式的字符串,称为“标识”,
    用来标记JPEG文件的 信息段。“0xFFD8”表示图像 信息开始,“0xFFD9”表示图像 信息结束,这两个标识后面没有 信息,而其它标识紧跟一些 信息字符。
    0xFFE0 -- 0xFFEF之间的标识符称为“应用标记”,没有被常规JPEG文件利用,Exif正是利用这些 信息串记录拍摄 信息如快门速度、光圈值等,
    甚至可以包括全球定位 信息。按照Exif2.1标准对这些标识符的定义,数码相机可以把各种拍摄 信息记入数码图像中,应用软件可以读取这些数据,
    再按照Exif2.1标准,检索出它们的具体含义。


    GPS,Global Positioning System(全球卫星定位系统),是美国从20世纪70年代开始耗巨资研制,于1994年全面建成,具有在海、陆、空进行全方位
    实时三维导航与定位能力的新一代卫星导航与定位系统。
    越来越多的数码相机厂商也开始在他们的新产品里提供了GPS功能的支持,(如Kodak DCS760等)可将照片拍摄瞬间所处经度、纬度、海拔的三维空间
    定位数据记载在 图片里,只要 图片里保留了完整的 GPS  信息,IExif 就能准确地再现给查看者。        


   jpg整个文件的大体结构,由标记块组成,一般标记块由标记码(2字节)+长度(2字节)+数据(长度n),只有SOI和EOI没有长度和数据。长度为大端数据。
   标记码由两个字节构成,其前一个字节是固定值0xFF,后一个字节则根据不同意义有不同数值。
   JFIF格式的JPEG文件(*.jpg)的一般顺序为:
    SOI(0xFFD8)            Start of Image,图像开始
    APP0(0xFFE0)         Application,应用程序0
    [APPn(0xFFEn)]可选   Application,应用程序n
    DQT(0xFFDB)          Define Quantization Table,定义量化表
    SOF0(0xFFC0)         Start of Frame,帧图像开始
    DHT(0xFFC4)           Difine Huffman Table,定义哈夫曼表
    SOS(0xFFDA)          Start of Scan,扫描开始 12字节
    压缩数据
    EOI(0xFFD9)            End of Image,图像结束 2字节
 
    (0xFF后的0xD0~0xD7,则组成RSTn标记)


   Exif格式的JPEG文件(*.jpg)的一般顺序为:
    SOI(0xFFD8)          Start of Image,图像开始
    APP1(0xFFE1)         Application,应用程序1   
    DQT(0xFFDB)          Define Quantization Table,定义量化表
    DHT(0xFFC4)          Difine Huffman Table,定义哈夫曼表
    SOF0(0xFFC0)         Start of Frame,帧图像开始
    SOS(0xFFDA)          Start of Scan,扫描开始 12字节
    压缩数据
    EOI(0xFFD9)          End of Image,图像结束 2字节

下面的内容是从Exif2-2.pdf上拷贝下来的:

   APP1的组成:  
    APP1 Marker          FF E1
    Length                      3A 59
    Exif Identifier Code Exif
    TIFF Header            MM 002A 00000008
    0th IFD
    ...
    Exif IFD
    1st IFD
    JPEGInterchangeFormat
    JPEGInterchangeFormatLength
    JPEG Thumbnail

 TIFF Header

    Name       Size (Bytes) Value
    Byte Order 2            either "II" (4949.H) (little endian) or "MM" (4D4D.H)(big endian)
     42        2            002A.H (fixed)    
    Offset IFD 4            0th IFD offset. If the TIFF header is followed immediately by the 0th IFD, it is written as 00000008.H.  
  JPEG Thumbnail组成:(Compressed Thumbnail)
    SOI
    DQT
    DHT
    SOF
    SOS
    Compressed Data
    EOI


    (0xFF后的0xD0~0xD7,则组成RSTn标记)
    
    采用了TIFF VER 6.0的文件头相关 信息。下面是Exif2-2的简要 信息
    File Header,
    0th IFD,
    0th IFD Value,
    1st IFD,
    1st IFD Value,
    1st (Thumbnail) Image Data,
    0th (Primary) Image Data.    


  IFD:
    2bytes  number of fields
    12bytes Tag:
      Bytes 0-1 Tag
      Bytes 2-3 Type
      Bytes 4-7 Count              The number of values, NOT bytes, such as SHORT,COUNT=1 is 2bytes
      Bytes 8-11 Value or Offset   This tag records the offset from the start of the TIFF header In cases where the value fits in 4 bytes, the value itself is recorded
    4bytes  nextIFD
    
    TYPE:
    1 = BYTE An 8-bit unsigned integer.,
    2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.,
    3 = SHORT A 16-bit (2-byte) unsigned integer,
    4 = LONG A 32-bit (4-byte) unsigned integer,
    5 = RATIONAL Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator.,
    7 = UNDEFINED An 8-bit byte that can take any value depending on the field definition,
    9 = SLONG A 32-bit (4-byte) signed integer (2's complement notation),
    10 = SRATIONAL Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator.
    
    Exif IFD: Exif IFD is a set of tags for recording Exif-specific attribute information
    Exif IFD Pointer
    Tag = 34665 (8769.H)
    Type = LONG
    Count = 1
    Default = none  
    
    GPS IFD:GPS IFD is a set of tags for recording GPS information  
    GPS Info IFD Pointer
    Tag = 34853 (8825.H)    2bytes
    Type = LONG  0004       2bytes
    Count = 1   00000001    4bytes
    Default = none          4bytes 例:000002A2
    
    Interoperability IFD:Interoperability IFD is composed of tags which stores the information to ensure the Interoperability and pointed by
                         the following tag located in Exif IFD
    Interoperability IFD Pointer
    Tag = 40965 (A005.H)
    Type = LONG
    Count = 1
    Default = None  


    TIFF Rev. 6.0 Attribute Information
                                                                                          Tag ID
    Tag Name                    Field Name                           Dec Hex    Type                       Count        
A. Tags relating to image data structure
   Image width                  ImageWidth                            256 100 SHORT or LONG     1
   Image height                 ImageLength                          257 101 SHORT or LONG     1
   Number of bits per component BitsPerSample        258 102 SHORT                      3
   Compression scheme           Compression               259 103 SHORT                      1
   Pixel composition            PhotometricInterpretation 262 106 SHORT                       1
   Orientation of image         Orientation                        274 112 SHORT                       1
   Number of components         SamplesPerPixel        277 115 SHORT                       1
   Image data arrangement       PlanarConfiguration    284 11C SHORT                     1
   Subsampling ratio of Y to C  YCbCrSubSampling    530 212 SHORT                      2
   Y and C positioning          YCbCrPositioning             531 213 SHORT                      1
   Image resolution in width    XResolution                    282 11A RATIONAL                 1
   Image resolution in height   YResolution                    283 11B RATIONAL                 1
   Unit of X and Y resolution   ResolutionUnit                296 128 SHORT                       1
B. Tags relating to recording offset
   Image data location          StripOffsets                       273 111 SHORT or LONG    *S
   Number of rows per strip     RowsPerStrip                278 116 SHORT or LONG     1
   Bytes per compressed strip   StripByteCounts         279 117 SHORT or LONG    *S
   Offset to JPEG SOI           JPEGInterchangeFormat  513 201 LONG                       1
   Bytes of JPEG data         JPEGInterchangeFormatLength 514 202 LONG              1
C. Tags relating to image data characteristics
   Transfer function            TransferFunction                  301 12D SHORT            3 * 256
   White point chromaticity     WhitePoint                      318 13E RATIONAL                2
   Chromaticities of primaries  PrimaryChromaticities 319 13F RATIONAL               6
   Color transf matrix coef     YCbCrCoefficients          529 211 RATIONAL                3
   Pair of black and white refl ReferenceBlackWhite    532 214 RATIONAL               6
D. Other tags
   File change date and time    DateTime                     306 132 ASCII                       20
   Image title                  ImageDescription                     270 10E ASCII           Any
   Image input equipment manuf  Make                         271 10F ASCII           Any
   Image input equipment model  Model                        272 110 ASCII           Any
   Software used                Software                              305 131 ASCII           Any
   Person who created the image Artist                        315 13B ASCII           Any
   Copyright holder             Copyright                      33432 8298 ASCII          Any    


*S Chunky format: StripsPerImage
   Planar format: SamplesPerImage * StripsPerImage
   StripsPerImage = floor((ImageLength + RowsPerStrip -1)/ RowsPerStrip)


   
   Exif IFD Attribute Information
                                                                                                       Tag ID
    Tag Name                    Field Name                                         Dec   Hex  Type                     Count        
A. Tags Relating to Version
    Exif version                ExifVersion                                           36864 9000 UNDEFINED      4
    Supported Flashpix version  FlashpixVersion                      40960 A000 UNDEFINED      4
B. Tag Relating to Image Data Characteristics
    Color space information     ColorSpace                                40961 A001 SHORT                1
C. Tags Relating to Image Configuration
    Meaning of each component   ComponentsConfiguration   37121 9101 UNDEFINED      4
    Image compression mode      CompressedBitsPerPixel    37122 9102 RATIONAL           1
    Valid image width           PixelXDimension                           40962 A002 SHORT or LONG  1
    Valid image height          PixelYDimension                           40963 A003 SHORT or LONG  1
D. Tags Relating to User Information
    Manufacturer notes          MakerNote                                     37500 927C UNDEFINED    Any
    User comments               UserComment                                37510 9286 UNDEFINED    Any
E. Tag Relating to Related File Information
    Related audio file          RelatedSoundFile                            40964 A004 ASCII         13
F. Tags Relating to Date and Time
    Date time of orig data gen  DateTimeOriginal                      36867 9003 ASCII         20
    Date time of digi data gen  DateTimeDigitized                    36868 9004 ASCII         20
    DateTime subseconds         SubSecTime                              37520 9290 ASCII        Any
    DateTimeOriginal subseconds SubSecTimeOriginal          37521 9291 ASCII        Any
    DateTimeDigitized subseconds SubSecTimeDigitized      37522 9292 ASCII        Any
G. Tags Relating to Picture-Taking Conditions
See Table 5
H. Other Tags
    Unique image ID             ImageUniqueID                               42016 A420 ASCII         33


G. Tags Relating to Picture-Taking Conditions
    Exposure time               ExposureTime                                 33434 829A RATIONAL       1
    F number                    FNumber                                             33437 829D RATIONAL       1
    Exposure program            ExposureProgram                      34850 8822 SHORT          1
    Spectral sensitivity        SpectralSensitivity                         34852 8824 ASCII        Any
    ISO speed rating            ISOSpeedRatings                         34855 8827 SHORT        Any
    Optoelectric conv factor    OECF                                         34856 8828 UNDEFINED    Any
    Shutter speed               ShutterSpeedValue                        37377 9201 SRATIONAL      1
    Aperture                    ApertureValue                                     37378 9202 RATIONAL       1
    Brightness                  BrightnessValue                               37379 9203 SRATIONAL      1
    Exposure bias               ExposureBiasValue                      37380 9204 SRATIONAL      1
    Maximum lens aperture       MaxApertureValue                  37381 9205 RATIONAL       1
    Subject distance            SubjectDistance                            37382 9206 RATIONAL       1
    Metering mode               MeteringMode                              37383 9207 SHORT          1
    Light source                LightSource                                      37384 9208 SHORT          1
    Flash                       Flash                                                      37385 9209 SHORT          1
    Lens focal length           FocalLength                                   37386 920A RATIONAL       1
    Subject area                SubjectArea                                     37396 9214 SHORT      2 or 3 or 4
    Flash energy                FlashEnergy                                    41483 A20B RATIONAL       1
    Spatial frequency response  SpatialFrequencyResponse  41484 A20C UNDEFINED    Any
    Focal plane X resolution    FocalPlaneXResolution          41486 A20E RATIONAL       1
    Focal plane Y resolution    FocalPlaneYResolution           41487 A20F RATIONAL       1
    Focal plane resolution unit FocalPlaneResolutionUnit      41488 A210 SHORT          1
    Subject location            SubjectLocation                             41492 A214 SHORT          2
    Exposure index              ExposureIndex                              41493 A215 RATIONAL       1
    Sensing method              SensingMethod                           41495 A217 SHORT          1
    File source                 FileSource                                         41728 A300 UNDEFINED      1
    Scene type                  SceneType                                       41729 A301 UNDEFINED      1
    CFA pattern                 CFAPattern                                     41730 A302 UNDEFINED    Any
    Custom image processing     CustomRendered              41985 A401 SHORT          1
    Exposure mode               ExposureMode                          41986 A402 SHORT          1
    White balance               WhiteBalance                               41987 A403 SHORT          1
    Digital zoom ratio          DigitalZoomRatio                         41988 A404 RATIONAL       1
    Focal length in 35 mm film  FocalLengthIn35mmFilm     41989 A405 SHORT          1
    Scene capture type          SceneCaptureType                 41990 A406 SHORT          1
    Gain control                GainControl                                     41991 A407 RATIONAL       1
    Contrast                    Contrast                                             41992 A408 SHORT          1
    Saturation                  Saturation                                         41993 A409 SHORT          1
    Sharpness                   Sharpness                                      41994 A40A SHORT          1
    Device settings description DeviceSettingDescription  41995 A40B UNDEFINED    Any
    Subject distance range      SubjectDistanceRange         41996 A40C SHORT          1
 
GPS Attribute Information
                                                                                               Tag ID
    Tag Name                    Field Name                              Dec   Hex  Type           Count        
A. Tags Relating to GPS
   GPS tag version              GPSVersionID                      0     0    BYTE                4
   North or South Latitude      GPSLatitudeRef                1     1    ASCII                2
   Latitude                     GPSLatitude                                 2     2    RATIONAL       3
   East or West Longitude       GPSLongitudeRef           3     3    ASCII                2
   Longitude                    GPSLongitude                           4     4    RATIONAL       3
   Altitude reference           GPSAltitudeRef                     5     5    BYTE                1
   Altitude                     GPSAltitude                                   6     6    RATIONAL       1
   GPS time (atomic clock)      GPSTimeStamp              7     7    RATIONAL       3
   GPS satellites used          GPSSatellites                      8     8    ASCII            Any
   GPS receiver status          GPSStatus                          9     9    ASCII                 2
   GPS measurement mode         GPSMeasureMode   10    A    ASCII                2
   Measurement precision        GPSDOP                        11    B    RATIONAL       1
   Speed unit                   GPSSpeedRef                          12    C    ASCII                2
   Speed of GPS receiver        GPSSpeed                      13    D    RATIONAL       1
   Reference dir of movement    GPSTrackRef               14    E    ASCII                 2
   Direction of movement        GPSTrack                         15    F    RATIONAL       1
   Reference direction of image GPSImgDirectionRef   16   10    ASCII                2
   Direction of image           GPSImgDirection                 17   11    RATIONAL       1
   Geodetic survey data used    GPSMapDatum             18   12    ASCII            Any
   Reference latitude of dest   GPSDestLatitudeRef       19   13    ASCII                2
   Latitude of destination      GPSDestLatitude                20   14    RATIONAL       3
   Reference longitude of dest  GPSDestLongitudeRef  21   15    ASCII                2
   Longitude of destination     GPSDestLongitude           22   16    RATIONAL       3
   Reference bearing of dest    GPSDestBearingRef      23   17    ASCII                2
   Bearing of destination       GPSDestBearing                24   18    RATIONAL       1
   Reference distance to dest   GPSDestDistanceRef    25   19    ASCII                2
   Distance to destination      GPSDestDistance              26   1A    RATIONAL       1
   Name GPS process method GPSProcessingMethod 27   1B    UNDEFINED    Any
   Name of GPS area             GPSAreaInformation          28   1C    UNDEFINED    Any
   GPS date                     GPSDateStamp                         29   1D    ASCII              11
   GPS differential correction  GPSDifferential                30   1E    SHORT              1


如何 分析一个Exif的jpg文件中的gps 信息
   实例 分析:PICT0021.JPG
00   FF D8 FF E1 3A 59 45 78 69 66 00 00 4D 4D 00 2A 
10   00 00 00 08 00 0C 01 0E 00 02 00 00 00 0E 00 00
20   03 F4 01 0F 00 02 00 00 00 20 00 00 04 02 01 10
30   00 02 00 00 00 20 00 00 04 22 01 12 00 03 00 00
40   00 01 00 01 00 00 01 1A 00 05 00 00 00 01 00 00
50   04 42 01 1B 00 05 00 00 00 01 00 00 04 4A 01 28
60   00 03 00 00 00 01 00 02 00 00 01 31 00 02 00 00 
70   00 20 00 00 04 52 01 32 00 02 00 00 00 14 00 00
80   04 72 02 13 00 03 00 00 00 01 00 01 00 00 87 69
90   00 04 00 00 00 01 00 00 00 9E 88 25 00 04 00 00
A0   00 01 00 00 02 A2 00 00 02 E4 00 28 82 9A 00 05
B0   00 00 00 01 00 00 04 86 82 9D 00 05 00 00 00 01
C0   00 00 04 8E 88 22 00 03 00 00 00 01 00 02 00 00
D0   88 27 00 03 00 00 00 01 00 C8 00 00 90 00 00 07
E0   00 00 00 04 30 32 32 31 90 03 00 02 00 00 00 14
F0   00 00 04 96 90 04 00 02 00 00 00 14 00 00 04 AA
100  91 01 00 07 00 00 00 04 01 02 03 00 91 02 00 05
110  00 00 00 01 00 00 04 BE 92 01 00 0A 00 00 00 01
120  00 00 04 C6 92 02 00 05 00 00 00 01 00 00 04 CE
130  92 04 00 0A 00 00 00 01 00 00 04 D6 92 05 00 05
140  00 00 00 01 00 00 04 DE 92 06 00 05 00 00 00 01
150  00 00 04 E6 92 07 00 03 00 00 00 01 00 02 00 00
160  92 08 00 03 00 00 00 01 00 00 00 00 92 09 00 03
170  00 00 00 01 00 20 00 00 92 0A 00 05 00 00 00 01
180  00 00 04 EE 92 7C 00 07 00 00 00 40 00 00 04 F6
190  A0 00 00 07 00 00 00 04 30 31 30 30 A0 01 00 03
1A0  00 00 00 01 00 01 00 00 A0 02 00 04 00 00 00 01
1B0  00 00 12 00 A0 03 00 04 00 00 00 01 00 00 0D 80
1C0  A0 05 00 04 00 00 00 01 00 00 02 84 A2 15 00 05
1D0  00 00 00 01 00 00 05 36 A2 17 00 03 00 00 00 01
1E0  00 02 00 00 A3 00 00 07 00 00 00 01 03 00 00 00
1F0  A3 01 00 07 00 00 00 01 01 00 00 00 A4 01 00 03
200  00 00 00 01 00 00 00 00 A4 02 00 03 00 00 00 01
210  00 00 00 00 A4 03 00 03 00 00 00 01 00 00 00 00
220  A4 04 00 05 00 00 00 01 00 00 05 3E A4 05 00 03
230  00 00 00 01 00 29 00 00 A4 06 00 03 00 00 00 01
240  00 00 00 00 A4 07 00 03 00 00 00 01 00 00 00 00
250  A4 08 00 03 00 00 00 01 00 00 00 00 A4 09 00 03
260  00 00 00 01 00 00 00 00 A4 0A 00 03 00 00 00 01
270  00 00 00 00 A4 0B 00 07 00 00 00 04 00 00 00 00
280  A4 0C 00 03 00 00 00 01 00 00 00 00 00 00 00 00
290  00 02 00 01 00 02 00 00 00 04 52 39 38 00 00 02
2A0  00 07 00 00 00 04 30 31 30 30 00 00 00 00 00 05
2B0  00 00 00 01 00 00 00 04 02 02 00 00 00 01 00 02
2C0  00 00 00 02 4E 00 00 00 00 02 00 05 00 00 00 03
2D0  00 00 05 46 00 03 00 02 00 00 00 02 45 00 00 00
2E0  00 04 00 05 00 00 00 03 00 00 05 5E 00 00 00 00
2F0  00 06 01 03 00 03 00 00 00 01 00 06 00 00 01 1A
300  00 05 00 00 00 01 00 00 05 76 01 1B 00 05 00 00
310  00 01 00 00 05 7E 01 28 00 03 00 00 00 01 00 02
320  00 00 02 01 00 04 00 00 00 01 00 00 07 F4 02 02
330  00 04 00 00 00 01 00 00 32 5D 00 00 00 00 00 00
   
   FF D8       SOI
   FF E1       APP1
   3A 59       APP1 LENGTH
   45 78 69 66 00 00 Exif ASCII结束符两个
   4D 4D       MM big endian TIFF Header (注意小端的为:49492A00 08000000)
   00 2A       fixed
   00 00 00 08 IFD0 offset
   00 0C       IFD0: number of TAGs 12个tag,每个12字节。
   01 0E       TAG      Image title   
   00 02       TYPE ASCII
   00 00 00 0E count   最多13个字符
   00 00 03 F4 offset +0C=0x400 可以看到DCIM\100MEDIA (0x0c from the start of the TIFF header 4D4D MM)


   01 0F       TAG Image input equipment manuf 
   00 02       TYPE ASCII
   00 00 00 20 count   最多31个字符
   00 00 04 02 offset +0c=0x040E 可以看到TCL


   01 10       TAG Image input equipment model 
   00 02       TYPE ASCII
   00 00 00 20 count
   00 00 04 22 offset +0c=0x042E 可以看到SDV05
   
   01 12       TAG Orientation of image 
   00 03       SHORT             00 01
   00 00 00 01 count
   00 01 00 00 value 
   
   01 1A       TAG Image resolution in width 0x0442+0c=0x44E,可以看到00 00 00 48/00 00 00 01
   00 05       RATIONAL 
   00 00 00 01 count
   00 00 04 42 offset +0c=0x44E,可以看到00 00 00 48/00 00 00 01
   
   01 1B       TAG Image resolution in height 
   00 05       RATIONAL
   00 00 00 01 
   00 00 04 4A offset+0c=0x456 可以看到00 00 00 48/00 00 00 01
   
   01 28       Unit of X and Y resolution
   00 03       SHORT                00 02
   00 00 00 01 
   00 02 00 00 
   
   01 31       Software used 
   00 02       ASCII
   00 00 00 20 count
   00 00 04 52 offset +0c =0x45E 可以看到0.0.2
   
   01 32       DateTime 
   00 02       ASCII
   00 00 00 14 20字节
   00 00 04 72 offset+0c=0x47E,可以看到2012:07:29 21:28:18
   
   02 13       YCbCrPositioning
   00 03       SHORT      00 01
   00 00 00 01 
   00 01 00 00
   
   87 69       Exif IFD Pointer
   00 04       LONG
   00 00 00 01 count
   00 00 00 9E offset+0c=0xAA
   
   88 25       GPS Info IFD Pointer
   00 04       LONG
   00 00 00 01 count
   00 00 02 A2 offset+0c=0x02AE
   
   00 00 02 E4 nextIFD IFD1 offset
   
   00 28  Exif IFD number of TAGs
   82 9A  ExposureTime
   00 05  RATIONAL
   00 00 00 01 count
   00 00 04 86 offset+0c=0x0492
   ...

   Exif的相关信息这里先不做分析,请大家参照上面的文档自己分析了。

   

   这里主要是分析GPS相关信息

   GPS Info IFD Pointer 0x02AE  从上面数据2A0行的后面看数据
   00 05       count of TAGs
   
   00 00       GPSVersionID
   00 01       BYTE
   00 00 00 04 count
   02 02 00 00 value 2.2.0.0
   
   00 01       GPSLatitudeRef
   00 02       ASCII
   00 00 00 02 count
   4E 00 00 00 N North  
   
   00 02       GPSLatitude
   00 05       RATIONAL               前4字节为分子,后4字节为分母,十六进制先转为十进制
   00 00 00 03 count
   00 00 05 46 offset+0c=0x552 16 00 00 00 01 00 00 00 22 00 00 00 01 00 00 00 51 00 00 00 04 00 00 00
                                                       22/1=22                             34/1=34                              81/4= 20.25
                                                      通过windows的右键属性看详细 信息:22;34;20.249999999999915
   00 03       GPSLongitudeRef
   00 02
   00 00 00 02 count
   45 00 00 00 East
   
   00 04       GPSLongitude
   00 05       RATIONAL
   00 00 00 03 count
   00 00 05 5E offset+0c=0x56A 71 00 00 00 01 00 00 00 37 00 00 00 01 00 00 00 6C 00 00 00 04 00
                                                       113/1=113                          55/1=55                             108/4=27
                                                    通过windows的右键属性看详细 信息:113;55;27.000000000000171

550 04 00 16 00 00 00 01 00 00 00 22 00 00 00 01 00 
560 00 00 51 00 00 00 04 00 00 00 71 00 00 00 01 00
570 00 00 37 00 00 00 01 00 00 00 6C 00 00 00 04 00
580 00 00 00 00 00 48 00 00 00 01 00 00 00 48 00 00
590 00 01 00 00 00 00 00 00
   主要 分析gps相关 信息
   对于Exif的相关 信息可以参照tag进行 分析

猜你喜欢

转载自blog.csdn.net/yapingmcu/article/details/50638713
今日推荐