Main Menu

Lens from exif

Started by eliz, September 04, 2011, 04:20:31 AM

Previous topic - Next topic

eliz

hello, i'm currently trying to implement a lens identification from exif in a PHP library (exifixer 1.5) for canon and nikon cameras
http://webscripts.softpedia.com/script/Image-Galleries/Image-Tools/Exifier-42424.html

i have read the documentation from here:
http://www.exiftool.org/TagNames/Nikon.html#LensData0204
but i have some problems with nikon lensdata from address 0x0098 .
i tried command: exiftool -v4 -w txt image.jpg
and this data is returned at 0x0098 :

33) LensData0201 (SubDirectory) -->
- Tag 0x0098 (31 bytes, undef[31]):
0950: 30 32 30 31 5a e5 59 c4 31 e3 3d e8 a2 9e 7b fc
0960: a0 43 2d a5 27 e0 60 8c d8 13 3d 56 5e 57 3e
+ [Decrypted LensData0201 directory]
0950: 30 32 30 31 10 3c 0e 00 11 88 98 26 44 73 98 34
0960: 3c 1c 3c 17 65 21 4f 00 00 00 00 00 00 02 05

my lens is in the decrypted data: '26 44 73 98 34 3C 1C 02'   = Sigma 135-400mm F4.5-5.6 APO Aspherical

in my PHP library at the 0098 address i'm reading exactly: 30 32 30 31 5a e5 59 c4 31 e3 3d e8 a2 9e 7b fc a0 43 2d a5 27 e0 60 8c d8 13 3d 56 5e 57 3e

my question is how I decrypt this to: 30 32 30 31 10 3c 0e 00 11 88 98 26 44 73 98 34 3c 1c 3c 17 65 21 4f 00 00 00 00 00 00 02 05 ?

Phil Harvey

Look at the Decrypt() function in lib/Image/ExifTool/Nikon.pm of the full ExifTool distribution.

The source code also contains comments and references which may be useful for developers, so you should be looking at the source code of other modules too.

- 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 ($).

eliz

thanks for info.
another question. i have implemented the lenstype for canon in php. but for third party camera example Sigma 150mm f/2.8 macro the decimal 173 is returned. That number coresponding to "Canon 180mm f/2.8 macro or Sigma lens". but i have seen that exiftool see the correct version of the lens (sigma 150mm) .
is this done by comparing the LensId, focal length & aperture to guess the third party lens ?

Phil Harvey

Quote from: eliz on September 04, 2011, 10:52:09 AM
is this done by comparing the LensId, focal length & aperture to guess the third party lens ?

Yes, this is the idea.  See PrintLensID() in Canon.pm for details.  But the Canon algorithm is different than other makes which use another  PrintLensID() function in Exif.pm.

- 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 ($).