drewnoakes / metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Apache License 2.0
2.58k stars 480 forks source link

Not returning the correct values on Canon Makernote #138

Open eicm opened 8 years ago

eicm commented 8 years ago

The changes made in #136 now reads the canon maker note but it doesn't return the correct value. For example for the linked pictures it returns 0 for lens type and empty string for lens model: IMG_1782 (Medium).JPG.zip piano.006.zip

payton commented 5 years ago

We are properly reading the tag and its corresponding type/length. The LensModel tag, for example, identifies it as a String of 70 bytes. However, we are getting the offset wrong at some point.

ExifTool properly extracts this data. Using ExifTool's -htmldump option, I see there is a negative base offset, which we don't identify. I'm still trying to determine where this offset comes from. Subtracting that offset from our identified tag value offset properly identifies the lens model.

screen shot 2019-01-11 at 11 45 45 am

This data was extracted from the provided image (IMG_1782...). ExifTool displays the actual offset as being 0x0e52 (3666), which is 30 bytes off if you jump to that index in HexFiend or another Hex editor. The 30 bytes represent the offset to the beginning of the TIFF file.

Unsure of where the -164 base offset comes from.

payton commented 5 years ago

This issue relates to a special case with Canon Makernotes. ExifTool actually has a dedicated option for fixing this. According to ExifTool, it occurs when the TIFF footer has the original offset.

exiftool -fixBase FILE_PATH

drewnoakes commented 5 years ago

There are various special case rules for different makernote offset roots. Seems like we need another here.