Project

General

Profile

Error: pointer references previously read

Added by Luis Diaz over 6 years ago

Hi all,

I'm using exiv2 to read the metadata of my images and I have a problem with a particular set of images. This is the output that prints exiv2 (sorry for the Spanish output :P):

Error: (Last IFD item) pointer references previously read (Last IFD item) directory. Ignored.
Error: GPSInfo pointer references previously read (Last IFD item) directory. Ignored.
Error: Thumbnail pointer references previously read (Last IFD item) directory. Ignored.
Nombre de archivo: /media/linData/Nolan/00_ORIGINAL/images/2015_0721_152036_189.JPG
Tamaño de archivo: 3965395 Bytes
Tipo de MIME    : image/jpeg
Tamaño de imagen: 4032 x 3024
Fabricante de la camara: PEAU PRODUCTIONS
Modelo de la cámara: MAPIR
Fecha de la imagen: 2015:07:21 15:20:36
Número de imagen: 
Tiempo de exposición: 1/1210 s
Apertura        : F2.8
Ajuste de exposición: 0 EV
Flash           : No, modo compulsivo
Ajuste del flash: 
Distancia focal : 4.3 mm (equivalente 35mm: 31.0 mm)
Distancia al objetivo: 
Velocidad ISO   : 50
Modo de exposición: Automático
Modo de métrica: Promedio
Modo de macro   : 
Calidad de imagen: 
Resolución Exif: 4032 x 3024
Balance de blancos: Automático
Miniatura       : Ninguno
Copyright       : 
Comentario Exif :

The thing is that other tools such a exiftool, achieves to read all the information (including the GPS info, that is the most relevant information for my purposes). This is the exiftool output:

ExifTool Version Number         : 9.46
File Name                       : 2015_0721_152036_189.JPG
Directory                       : /media/linData/Nolan/00_ORIGINAL/images
File Size                       : 3.8 MB
File Modification Date/Time     : 2015:07:22 18:59:12+02:00
File Access Date/Time           : 0000:00:00 00:00:00
File Inode Change Date/Time     : 2015:07:24 09:18:25+02:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Camera Model Name               : MAPIR
Software                        : G20150624V01
Orientation                     : Horizontal (normal)
Modify Date                     : 2015:07:21 15:20:36
Y Cb Cr Positioning             : Co-sited
Resolution Unit                 : inches
X Resolution                    : 72
Y Resolution                    : 72
Image Description               : CAMERA
Make                            : PEAU PRODUCTIONS
Exif Version                    : 0220
Flashpix Version                : 0100
File Source                     : Digital Camera
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/1176
Color Space                     : sRGB
Scene Type                      : Directly photographed
Custom Rendered                 : Normal
Aperture Value                  : 1.7
Exif Image Width                : 4032
Exposure Mode                   : Manual
Date/Time Original              : 2015:07:21 15:20:36
Brightness Value                : 1
Exif Image Height               : 3024
White Balance                   : Auto
Create Date                     : 2015:07:21 15:20:36
Exposure Compensation           : 0
Digital Zoom Ratio              : 0
Max Aperture Value              : 2.6
Focal Length In 35mm Format     : 31 mm
User Comment                    : 
Scene Capture Type              : Standard
Metering Mode                   : Average
Light Source                    : Unknown
Flash                           : Off, Did not fire
Focal Length                    : 4.4 mm
Sharpness                       : Normal
Sensing Method                  : One-chip color area
Exposure Time                   : 1/1210
F Number                        : 2.8
Exposure Program                : Program AE
ISO                             : 50
Lens Make                       : Peau Productions
Lens Model                      : GP43528
Warning                         : [minor] Unrecognized MakerNotes
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Altitude Ref                : Above Sea Level
Compression                     : JPEG (old-style)
Thumbnail Length                : 14158
Thumbnail Offset                : 1173
Image Width                     : 4032
Image Height                    : 3024
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
Aperture                        : 2.8
GPS Altitude                    : 154 m Above Sea Level
GPS Latitude                    : 33 deg 5' 13.49" N
GPS Longitude                   : 116 deg 57' 28.89" W
GPS Position                    : 33 deg 5' 13.49" N, 116 deg 57' 28.89" W
Image Size                      : 4032x3024
Scale Factor To 35 mm Equivalent: 7.1
Shutter Speed                   : 1/1210
Thumbnail Image                 : (Binary data 14158 bytes, use -b option to extract)
Circle Of Confusion             : 0.004 mm
Field Of View                   : 60.3 deg
Focal Length                    : 4.3 mm (35 mm equivalent: 31.0 mm)
Hyperfocal Distance             : 1.60 m
Light Value                     : 14.2

Do you think that some exif data could be corrupted? it could be some bug in exiv2? I tried to debug the problem in the exiv2 library, and these error messages are printed in tiffvisitor.cpp file [TiffReader::circularReference function].

I attached of of those images to the post.

I Hope you can help me :)


Replies (4)

RE: Error: pointer references previously read - Added by Andreas Huggel over 6 years ago

The Exif metadata structure of this image has problems: The Exif IFD and Interop IFD both have a Next IFD offset which points to the GPS IFD. The GPS IFD has a Next IFD offset which points to IFD1 (the Thumbnail IFD). All these Next IFD offsets should be 0.

Exiv2's circular reference check gets triggered by this and ignores the actual GPS IFD and Thumbnail IFD, simply because these are only processed after the above wrong Next IFD pointers.

A better behaviour would be for Exiv2 to ignore the wrong Next IFD pointers instead, like what exiftool seems to do.

Andreas

RE: Error: pointer references previously read - Added by Robin Mills over 6 years ago

Thanks to Andreas for the explanation concerning the circular reference. I'd like to make an observation about recovering the GPS information from this file. The procedure used here to extract the APP1 section with dd and process it with Exiv2 is described here: http://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_TIFF_files

I've printed the structure of your JPG with the -pS option. You can see the APP1/Exiv2 data starting at byte4.

543 rmills@rmillsmbp:~/Downloads $ exiv2 -pS 2015_0721_152011_181.JPG 
STRUCTURE OF JPEG FILE: 2015_0721_152011_181.JPG
 address | marker     | length  | data
       2 | 0xd8 SOI   |       0 
       4 | 0xe1 APP1  |   13471 | Exif..II*...................1..
   13477 | 0xdb DQT   |     132 
   13611 | 0xc0 SOF0  |      17 
   13630 | 0xc4 DHT   |     418 
   14050 | 0xda SOS   |      12 
544 rmills@rmillsmbp:~/Downloads 
The APP1 section is in TIFF format, so I've extracted it with dd and processed the TIFF with the -pS option
544 rmills@rmillsmbp:~/Downloads $ dd bs=1 skip=12 if=2015_0721_152011_181.JPG | exiv2 -pS -
3894149+0 records in
3894149+0 records out
3894149 bytes transferred in 5.192869 secs (749903 bytes/sec)
STRUCTURE OF TIFF FILE (II): 1438070944.exiv2_temp
 address |    tag                           |      type |    count |   offset | value
      10 | 0x0110 Model                     |     ASCII |        6 |      182 | MAPIR
      22 | 0x0131 Software                  |     ASCII |       13 |      188 | G20150624V01
      34 | 0xff01                           |     ASCII |       11 |      201 | N33.085873
      46 | 0x0112 Orientation               |     SHORT |        1 |        1 | 1
      58 | 0x0132 DateTime                  |     ASCII |       20 |      212 | 2015:07:21 15:20:11
      70 | 0xff02                           |     ASCII |       12 |      232 | W116.958071
      82 | 0x0213 YCbCrPositioning          |     SHORT |        1 |        2 | 2
      94 | 0x0128 ResolutionUnit            |     SHORT |        1 |        2 | 2
     106 | 0x011a XResolution               |  RATIONAL |        1 |      244 | 244/0
     118 | 0x011b YResolution               |  RATIONAL |        1 |      252 | 252/0
     130 | 0x010e ImageDescription          |     ASCII |        7 |      260 | CAMERA
     142 | 0x010f Make                      |     ASCII |       17 |      267 | PEAU PRODUCTIONS
     154 | 0x8769 ExifTag                   |      LONG |        1 |      284 | 284
     166 | 0x8825 GPSTag                    |      LONG |        1 |      933 | 933
    1069 | 0x0103 Compression               |     SHORT |        1 |        6 | 6
    1081 | 0x0128 ResolutionUnit            |     SHORT |        1 |        2 | 2
    1093 | 0x011a XResolution               |  RATIONAL |        1 |     1145 | 1145/0
    1105 | 0x011b YResolution               |  RATIONAL |        1 |     1153 | 1153/0
    1117 | 0x0202 JPEGInterchangeFormatLeng |      LONG |        1 |    12302 | 12302
    1129 | 0x0201 JPEGInterchangeFormat     |      LONG |        1 |     1161 | 1161
545 rmills@rmillsmbp:~/Downloads $ 
You can see that the GPS information has been stored as ASCII "N33.085873" and "W116.958071" at tags 0xff01 and 0xff02 respectively. I'm not a Metadata expert, so I don't know why those tags are being used by the camera/software that created this file. Here's the GPS information from a photograph at Stonehenge, England that I took with my Nikon D5300 a couple of weeks ago:
546 rmills@rmillsmbp:~/Downloads $ exiv2 -pv -g GPS ~/Pictures/2015/Stonehenge/DSC_7154.jpg  
0x8825 Image        GPSTag                      Long        1  4060
0x0000 GPSInfo      GPSVersionID                Byte        4  2 3 0 0
0x0001 GPSInfo      GPSLatitudeRef              Ascii       2  N
0x0002 GPSInfo      GPSLatitude                 Rational    3  51/1 106969/10000 0/1
0x0003 GPSInfo      GPSLongitudeRef             Ascii       2  W
0x0004 GPSInfo      GPSLongitude                Rational    3  1/1 495984/10000 0/1
0x0005 GPSInfo      GPSAltitudeRef              Byte        1  0
0x0006 GPSInfo      GPSAltitude                 Rational    1  97/1
0x0007 GPSInfo      GPSTimeStamp                Rational    3  14/1 38/1 5588/100
0x0008 GPSInfo      GPSSatellites               Ascii       3  09
0x0012 GPSInfo      GPSMapDatum                 Ascii      17  WGS-84          
0x001d GPSInfo      GPSDateStamp                Ascii      11  2015:07:16
547 rmills@rmillsmbp:~/Downloads $ 
It's obviously possible to write a bash script to read the 0xff01 and 0xff02 scripts and write the GPS tags using the conventional/standard GPSInfo Exif tags. It'd be good to get Exiv2(.exe) to correct the circular reference issue in TiffReader, however I don't know if/how that is possible. Maybe you'll get lucky and deleting the 0xff01 and 0xff02 tags will cause the APP1 section to be removed and the circular references will die in the process!

RE: Error: pointer references previously read - Added by Luis Diaz over 6 years ago

Thanks for the information, it's really helpful. We are using exiv2 at Pix4D for processing the EXIF data from hundreds of different cameras. In many cases the users handle their images with other applications that modify the EXIF data and we find cases like this one. I will keep you posted if I receive any relevant information from our client.

RE: Error: pointer references previously read - Added by Andreas Huggel over 6 years ago

I've created bug #1095 for this and checked-in a fix.
For the sample image, Exiv2 now reports warnings for the unexpected next pointers and processes the previously ignored IFDs.
Thanks for reporting this, Luis.

$ exiv2 -pa -u 2015_0721_152011_181.JPG 
Warning: Directory Photo has an unexpected next pointer; ignored.
Warning: Directory Iop has an unexpected next pointer; ignored.
Warning: Directory GPSInfo has an unexpected next pointer; ignored.
Exif.Image.Model                             Ascii       6  MAPIR
Exif.Image.Software                          Ascii      13  G20150624V01
Exif.Image.0xff01                            Ascii      11  N33.085873
Exif.Image.Orientation                       Short       1  top, left
Exif.Image.DateTime                          Ascii      20  2015:07:21 15:20:11
Exif.Image.0xff02                            Ascii      12  W116.958071
Exif.Image.YCbCrPositioning                  Short       1  Co-sited
Exif.Image.ResolutionUnit                    Short       1  inch
Exif.Image.XResolution                       Rational    1  72
Exif.Image.YResolution                       Rational    1  72
Exif.Image.ImageDescription                  Ascii       7  CAMERA
Exif.Image.Make                              Ascii      17  PEAU PRODUCTIONS
Exif.Image.ExifTag                           Long        1  284
Exif.Photo.ExifVersion                       Undefined   4  2.20
Exif.Photo.FlashpixVersion                   Undefined   4  1.00
Exif.Photo.FileSource                        Undefined   1  Digital still camera
Exif.Photo.ComponentsConfiguration           Undefined   4  YCbCr
Exif.Photo.ShutterSpeedValue                 SRational   1  1/1261 s
Exif.Photo.ColorSpace                        Short       1  sRGB
Exif.Photo.SceneType                         Undefined   1  Directly photographed
Exif.Photo.CustomRendered                    Short       1  Normal process
Exif.Photo.ApertureValue                     Rational    1  F1.7
Exif.Photo.PixelXDimension                   Short       1  4032
Exif.Photo.ExposureMode                      Short       1  Manual
Exif.Photo.DateTimeOriginal                  Ascii      20  2015:07:21 15:20:11
Exif.Photo.BrightnessValue                   SRational   1  1
Exif.Photo.PixelYDimension                   Short       1  3024
Exif.Photo.WhiteBalance                      Short       1  Auto
Exif.Photo.DateTimeDigitized                 Ascii      20  2015:07:21 15:20:11
Exif.Photo.ExposureBiasValue                 SRational   1  0 EV
Exif.Photo.DigitalZoomRatio                  Rational    1  0.0
Exif.Photo.MaxApertureValue                  Rational    1  F2.6
Exif.Photo.FocalLengthIn35mmFilm             Rational    1  31.0 mm
Exif.Photo.UserComment                       Undefined  20  
Exif.Photo.SceneCaptureType                  Short       1  Standard
Exif.Photo.MeteringMode                      Short       1  Average
Exif.Photo.LightSource                       Short       1  Unknown
Exif.Photo.Flash                             Short       1  No, compulsory
Exif.Photo.FocalLength                       Rational    1  4.3 mm
Exif.Photo.Sharpness                         Short       1  Normal
Exif.Photo.SensingMethod                     Short       1  One-chip color area
Exif.Photo.ExposureTime                      Rational    1  1/1278 s
Exif.Photo.FNumber                           Rational    1  F2.8
Exif.Photo.ExposureProgram                   Short       1  Auto
Exif.Photo.ISOSpeedRatings                   Short       1  50
Exif.Photo.LensMake                          Ascii      17  Peau Productions
Exif.Photo.LensModel                         Ascii       8  GP43528
Exif.Photo.MakerNote                         Undefined  16  0 48 53 54 0 0 165 165 16 120 57 0 232 2 1 0
Exif.Photo.InteroperabilityTag               Long        1  903
Exif.Iop.InteroperabilityIndex               Ascii       4  R98
Exif.Iop.InteroperabilityVersion             Undefined   4  1.00
Exif.Image.GPSTag                            Long        1  933
Exif.GPSInfo.GPSLatitudeRef                  Ascii       2  North
Exif.GPSInfo.GPSLatitude                     Rational    3  33deg 5' 9.142" 
Exif.GPSInfo.GPSLongitudeRef                 Ascii       2  West
Exif.GPSInfo.GPSLongitude                    Rational    3  116deg 57' 29.055" 
Exif.GPSInfo.GPSAltitudeRef                  Byte        1  Above sea level
Exif.GPSInfo.GPSAltitude                     Rational    1  125 m
Exif.Thumbnail.Compression                   Short       1  JPEG (old-style)
Exif.Thumbnail.ResolutionUnit                Short       1  inch
Exif.Thumbnail.XResolution                   Rational    1  72
Exif.Thumbnail.YResolution                   Rational    1  72
Exif.Thumbnail.JPEGInterchangeFormatLength   Long        1  12302
Exif.Thumbnail.JPEGInterchangeFormat         Long        1  1161
2015_0721_152011_181.JPG: (No XMP data found in the file)
    (1-4/4)