How to access tags like "LensInfo"?

Started by epet, April 05, 2013, 12:45:01 AM

Previous topic - Next topic

epet

Hi,

I have a question concerning access to tags like "LensInfo" (A432h).
I would like to read-out that information from Canon CR2 files.

I had been already successful, to read-out standard EXIF data from the first IFD.
According to the TIFF specification this IFD can be accessed easily.
Header:
- 49h 49h (Byte Order)
- 42h
- IFD – Offset
At IFD:
- 2 bytes number of entries
- 12 bytes per entry

But there is only one IFD present, terminated by 4 times 00h.

What special key-bytes I have to search for, to be able to access the required section?

The lens information is definitely available within the CR2 file. Exiftool can detect this information and Irfanview is showing it as well.

Best regards
epet

Phil Harvey

Hi Epet,

You must read the offset for the EXIF IFD from tag 0x8769, and parse this IFD.

You can use the exiftool -htmldump feature to help understand this structure.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

epet

Hi Phil,

Thank you very much for your quick answer!
I know the behavior of tag 0x8769. This tag is present at the first IFD.
But also the section which is addressed by that offset does not contain the LensInfo tag.

After parsing the offset area, no further IFD is recognized.

LensInfo obviously isn't a standard EXIF tag from the very first IFD.
When showing EXIF info by Irfanview, it is listed within the Maker Note section.

epet

Phil Harvey

Yes, the "LensInfo" tag may also be found in the maker notes (and in the XMP).  But it is part of the EXIF specification, and there it is found in the ExifIFD.

Try the -htmldump feature.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

epet

#4
Yes, the -htmldump feature helped a lot, thanks!

But I still didn't find what I have expected.
Within the MakerNotes section, now I found MakerNote tag 0x0002 called CanonFocalLength with the following value: 2 18 907 605. There is an '18' but no '55'. EDIT: 2 means Zoom, 18 means FocalLength, 3rd and 4th para used for digital zoom if applicable. The used lens is a Canon 18-55 IS. The MakerNote tag 0x0095 (LensModel) is 64 times 0x00.

When using Irfanview key 'E' (show EXIF), I get the following information: "Focal length: 18-55mm (1mm)". Therefore I expected a LensInfo tag with 4 times rational64u. But I still cannot find this tag within the whole html dump.

May it be possible, that Irfanview is decoding the lens type from the MakerNotes without the presence of a LensInfo tag, using a cross reference list for all lenses? But even my third party lens Tamron 17-35 is shown correctly as "17-35mm (1mm)".

epet

Phil Harvey

What model are we talking about?  I've taken a look at my sample images, and Models such as the T3i and T4i store the standard EXIF LensInfo.  Other lens parameters are stored inside binary data blocks in the maker notes.  These blocks are not broken down in the -htmldump output.  You need to use -v3 to see these.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

epet

The sample file I tried to analyze comes from a EOS 400D resp. XTi.
When using -htmldump -v3 the html file becomes 50MB in size and it takes about 1 minute to be opened with an Intel i5 2500 CPU!
Searching this file for "lens" does not show any further hits.

epet

Phil Harvey

No, sorry.  I'm meant -v3 instead of -htmldump.  Yes, a verbose HTML dump will be very large!

Just using -G1 -H, here is the lens-related information available in a 400D CR2 image:

[ExifIFD]       0x9202 Aperture Value                  : 4.5
[ExifIFD]       0x920a Focal Length                    : 50.0 mm
[Canon]         0x0016 Lens Type                       : Canon EF 50mm f/1.8 II
[Canon]         0x0017 Max Focal Length                : 50 mm
[Canon]         0x0018 Min Focal Length                : 50 mm
[Canon]         0x001a Max Aperture                    : 1.8
[Canon]         0x001b Min Aperture                    : 22
[Canon]         0x0001 Focal Length                    : 50 mm
[Canon]         0x0095 Lens Model                      : EF50mm f/1.8


All of the Canon information except LensModel is contained in the binary data blocks.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

epet

Ok, just to go sure, that I'm on the right way now:
I use the first MakerNotes entry called "CanonCameraSettings", at the corresponding position I take entry numbers 16h 17h 18h to get the required lens information (type, max and min focal length). At entry 17h I see a 12 00 (=18), at 18h I see a 37 00 (=55).

I hope, the scheme concerning entries 16h to 18h will be constant for all Canon DSLR, cause I have photos from 6 different models in my database.

Thank you very much for your quick and excellent support!

epet

Phil Harvey

Right.

You can look at the ExifTool source code to see if anything changes for different models.  (If so, there will be "Condition" statements in the definitions.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).