Jump to: navigation, search

Unique LensId

About an unique LensID tag

Okay, EXIF is great but Makernote is horrible. I really wonder when a new update in EXIF tag will be done ... Anyway. I spend a lot of time studying one part of images metadata, the lensID. It's a way to find which lens was plugged on a DSLR.

My goal

  • An lensID that is understandable : when reading it, you can understand it,
  • The most universal as possible ( should not depends on the maker ),
  • Accurate ( seems obvious but still want to say it ),
  • The same sigma lens canon and nikon mount should have quite the same ID ( my own quest of universality ).



Available metadata

Canon

Canon has not a long list of available data, but still has some :

  • In CameraSettings structure
    • LensType : an one byte id that should identify the lens for sure but there are many collision
    • LongFocal : maximum focal length
    • ShortFocal : minimal focal length
    • MaxAperture : maximum aperture at shoot focal
    • MinAperture : minimum aperture at shoot focal
    • FocalUnits : seems to give the unit for the focal length value

Interesting comment : look at the MaxAperture and MinAperture ( 2 last columns ). They vary with focal ).

 canon-10d-75-300mm-IMG_6890_75mm.JPG... 1 |  1.59 118.9     0.05  4.0  0.0  800 | 1203446885 | -1 75 300 32.0 4.0
 canon-10d-75-300mm-IMG_6891_100mm.JPG.. 1 |  1.59 158.6   0.0667  4.5  0.0  800 | 1203446890 | -1 75 300 32.0 4.0
 canon-10d-75-300mm-IMG_6892_135mm.JPG.. 1 |  1.59 222.0   0.0667  4.5  0.0  800 | 1203446897 | -1 75 300 32.0 4.5
 canon-10d-75-300mm-IMG_6893_200mm.JPG.. 1 |  1.59 317.2    0.125  4.5  0.0  800 | 1203446908 | -1 75 300 38.0 4.5
 canon-10d-75-300mm-IMG_6894_250mm.JPG.. 1 |  1.59 372.7      0.1  5.6  0.0  800 | 1203446917 | -1 75 300 38.0 4.5
 canon-10d-75-300mm-IMG_6895_300mm.JPG.. 1 |  1.59 475.8    0.167  5.6  0.0  800 | 1203446921 | -1 75 300 45.0 5.6
 Formulas :
   Aperture = exp( raw ) * ln(2) / 64

Comments : Many canon cameras don't have the LensType entry. For example 10D, 20D, 30D. This is a shame, because we could not have any unique ID of the lens with such camera.

Nikon

Nikon has already a pretty clever LensID. Everything is stored into the LensData tag. I pass over the fact that some datas can be encrypted into this structure on some cameras ( the decrypt function is known so we can get the values back ).

Here's what is available :

  • In LensData structure :
    • LensIDNumber ( => first part of lensID data )
    • LensFStop : stores the number of stops of this lens ( exemple : 6.3 fstop )
    • MinFocalLength : minimum focal length
    • MaxFocalLength : minimum focal length
    • MaxApertureAtMinFocal : maximum aperture at minimal focal length
    • MaxApertureAtMaxFocal : maximum aperture at maximum focal length
    • MCUVersion : seems to be a revision number or a serie version for the lens
  • Outside LensData structure
    • LensType : a char that codes the type of the lens : ( Bit 0 = MF, Bit 1 = D, Bit 2 = G, Bit 3 = VR )

The Nikon LensID is composed from the raw hex value of 8 others tags : LensIDNumber, LensIDNumber, LensFStops, MinFocalLength, MaxFocalLength, MaxApertureAtMinFocal, MaxApertureAtMaxFocal, MCUVersion and LensType

With this LensID, we already have huge list of associated lens, for example : '02 42 44 5C 2A 34 08 00' = AF Zoom-Nikkor 35-70mm f/3.3-4.5 But this is nothing comprehensible nor universal. More over the raw data for focal length is coded as well as aperture.

 Formulas :
   Focal = 5.0f * pow( 2, raw / 24.0f )
   Aperture = pow( 2, raw / 24.0f )
   FStop = raw / 12.0f

others coming soon


Proposal

Following the rules exposed in the headline, here's a proposal for an universal lensID value. The lens ID will be composed of theses values in this order. It stops when the next value is not accurate.

  • float : Minimum focal length ( float value, in mm )
  • float : Maximal focal length ( float value, in mm )
  • int  : LensIDNumber ( maker internal number )
  • float : Maximum aperture at minimal focal length
  • float : Maximum aperture at maximal focal length
  • float : Minimum aperture at minimal focal length
  • float : Minimum aperture at maximal focal length
  • int  : Revision number
  • text  : LensModel

Any null value will tell it was not decoded or is not available for this image. Normally, the order of those entries tells that the one that has the most signification is the top one.

Example of lensId codes :

 canon 10D + canon EF 75-300mm           : "75 300" ( you cannot get anything more with exif because lensType cannot be retrieved with a 10D)
 canon 40D + Canon EF 17-40mm f/4L       : "17  40 231" ( that's good and unique )
 canon 1DsMk2 + Canon EF 50mm f/1.4 USM  : "50  50 198" ( that's good and unique too )
 nikon D2x + 70-200                      : "70 200 119 2.8 2.8" ( good and unique too )
 nikon D70S + sigma 4.5                  : "5 5 254 2.8 2.8" ( good and unique too )

LensId.txt

This file will store all lenses to retrieve them according to the lensID we found. Here's the structure

 # Format : 
 #   ASCII text file ";" separated
 #   cell 1 : LensID from above
 #   cell 2 : Brand of the Lens
 #   cell 3 : Full long name of the lens
 #   cell 4 : 0:standard lens, 1:fisheye, 2:tilt/shift lens

Results of this system

Filename                                             Supported | Size Chan Depth| Lens      | S Brand Model                    | Sensor Focal Speed   Aperc Brk  Iso | UTC Time   | LensID                                             | Lock Full Size     | Lock 128x128 Size  
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
canon-10d-75-300mm-IMG_6890_75mm.JPG........................ 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 118.9     0.05  4.0  0.0  800 | 1203446885 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-75-300mm-IMG_6891_100mm.JPG....................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 158.6   0.0667  4.5  0.0  800 | 1203446890 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-75-300mm-IMG_6892_135mm.JPG....................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 222.0   0.0667  4.5  0.0  800 | 1203446897 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-75-300mm-IMG_6893_200mm.JPG....................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 317.2    0.125  4.5  0.0  800 | 1203446908 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-75-300mm-IMG_6895_300mm.JPG....................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 475.8    0.167  5.6  0.0  800 | 1203446921 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-IMG_6377_10D_17-70mm.JPG.......................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59  27.0     0.05  2.8  0.0  200 | 1203004953 | Not found (17 70)                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-IMG_6378_10D_50mm.JPG............................. 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59  79.3   0.0333  1.8  0.0  200 | 1203005000 | 6 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-10d-IMG_6380_10D_75-300mm.JPG......................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 118.9    0.167  4.0  0.0  200 | 1203005047 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-1D.jpg................................................ 1 | 1648 2464 3  8 | Fish    0 | 1 Canon Canon EOS-1D             |  1.25   4.9 0.000532  0.0  0.0  400 | 1006607269 | 100 possible lenses                                | 1648 2464 3  8  16 | 128  128 3  8  16
canon-300D-IMG_7419.JPG..................................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 300D DIGITAL   |  1.59  28.5    0.008  7.1  0.0  100 | 1150819015 | 3 possible lenses                                  | 2048 3072 3  8  16 | 128  128 3  8  16
canon-300D-img_9112.jpg..................................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 300D DIGITAL   |  1.59  28.5  0.00313 14.0  0.0  200 | 1140608445 | Not found (18 50)                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-50mm-10d.JPG.......................................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59  79.3   0.0222  1.8  0.0  200 | 1199458874 | 6 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
canon-75-300mm-10D.JPG...................................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 333.1    0.008  4.5  0.0  100 | 1201360012 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
nikon-D100-85mmF1.8D.JPG.................................... 1 | 3008 2000 3  8 | Std     0 | 1 NIKON CORPORATION NIKON D100   |  1.49 127.0    0.004  1.8 -0.7    0 | 1087850955 | Nikon AF Nikkor 85mm f/1.8D                        | 3008 2000 3  8  16 | 128  128 3  8  16
nikon-D200-20mm.jpg......................................... 1 | 2592 3872 3  8 | Std     0 | 1 NIKON CORPORATION NIKON D200   |  1.50  30.0  0.00625  8.0  0.0  100 | 1166973141 | Nikon AF Nikkor 20mm f/2.8D                        | 2592 3872 3  8  16 | 128  128 3  8  16
nikon-D200-_STF0098.JPG..................................... 1 | 2592 3872 3  8 | Std     0 | 1 NIKON CORPORATION NIKON D200   |  1.50  30.0  0.00625  8.0  0.0  100 | 1166973141 | Nikon AF Nikkor 20mm f/2.8D                        | 2592 3872 3  8  16 | 128  128 3  8  16
nikon-D2X-200mm.JPG......................................... 1 | 4288 2848 3  8 | Std     0 | 1 NIKON CORPORATION NIKON D2X    |  1.50 300.0   0.0167  8.0  0.0  800 | 1129140846 | Nikon AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED    | 4288 2848 3  8  16 | 128  128 3  8  16
nikon-D300-85mmF1.8D.JPG.................................... 1 | 4288 2848 3  8 | Std     0 | 1 NIKON CORPORATION NIKON D300   |  1.49 127.0   0.0167  4.5  0.0  200 | 1199732891 | Nikon AF Nikkor 85mm f/1.8D                        | 4288 2848 3  8  16 | 128  128 3  8  16
nikon-D70s-sigma4.5mm.JPG................................... 1 | 2000 3008 3  8 | Fish    0 | 1 NIKON CORPORATION NIKON D70s   |  1.40   7.0     0.77  4.5  0.0    0 | 1201716244 | Sigma 4.5mm F2.8 EX DC CIRCULAR FISHEYE HSM        | 2000 3008 3  8  16 | 128  128 3  8  16
ok-canon-10D-75-300mm-IMG_6894_250mm.JPG.................... 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59 372.7      0.1  5.6  0.0  800 | 1203446917 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
ok-canon-10D-sigma-24-70mm.JPG.............................. 1 | 3072 2048 3  8 | Std     0 | 1 Canon Canon EOS 10D            |  1.59  38.1   0.0167 19.0  0.0  400 | 1201351068 | 2 possible lenses                                  | 3072 2048 3  8  16 | 128  128 3  8  16
ok-canon-1DsII.jpg.......................................... 1 | 3328 4992 3  8 | Std     0 | 1 Canon Canon EOS-1Ds Mark II    |  1.00  50.0    0.004  4.0  0.0  500 | 1125758874 | Canon EF 50mm f/1.4 USM                            | 3328 4992 3  8  16 | 128  128 3  8  16
ok-canon-1DsIII-_AFP1060.JPG................................ 1 | 3744 5616 3  8 | Std     0 | 1 Canon Canon EOS-1Ds Mark III   |  1.00 300.0     0.02  8.0  0.0  100 | 1201089593 | Canon EF 300mm f/4L IS                             | 3744 5616 3  8  16 | 128  128 3  8  16
ok-canon-300D-img_9126.jpg.................................. 1 | 2048 3072 3  8 | Std     0 | 1 Canon Canon EOS 300D DIGITAL   |  1.59  28.5   0.0025 14.0  0.0  200 | 1140613868 | Not found (18 50)                                  | 2048 3072 3  8  16 | 128  128 3  8  16
ok-canon-30D-img_8400.jpg................................... 1 | 3504 2336 3  8 | Std     0 | 1 Canon Canon EOS 30D            |  1.60 112.0   0.0125  4.5  0.0 1600 | 1155034655 | 2 possible lenses                                  | 2336 3504 3  8  16 | 128  128 3  8  16
ok-canon-30D-img_8401.jpg................................... 1 | 3504 2336 3  8 | Std     0 | 1 Canon Canon EOS 30D            |  1.60 112.0     0.01  5.0  0.0  800 | 1155034667 | 2 possible lenses                                  | 2336 3504 3  8  16 | 128  128 3  8  16
ok-canon-350D-26445.JPG..................................... 1 | 1152 1728 3  8 | Std     0 | 1 Canon Canon EOS 350D DIGITAL   |  1.62  45.4    0.008  7.1  0.0  100 | 1148656874 | 3 possible lenses                                  | 1152 1728 3  8  16 | 128  128 3  8  16
ok-canon-350d-_MG_9425.JPG.................................. 1 | 1152 1728 3  8 | Std     0 | 1 Canon Canon EOS 350D DIGITAL   |  1.62  29.2    0.167 22.0  1.0  100 | 1127312105 | 3 possible lenses                                  | 1152 1728 3  8  16 | 128  128 3  8  16
ok-canon-400D-IMG_0119.JPG.................................. 1 | 3888 2592 3  8 | Std     0 | 1 Canon Canon EOS 400D DIGITAL   |  1.62  35.7    0.008  7.1  0.0  400 | 1159634304 | 3 possible lenses                                  | 3888 2592 3  8  16 | 128  128 3  8  16
ok-canon-40D-17mm.jpg....................................... 1 | 3935 2592 3  8 | Std     0 | 1 Canon Canon EOS 40D            |  1.63  27.7  0.00313 13.0  0.0  200 | 1194114457 | Canon EF 17-40mm f/4L                              | 2592 3935 3  8  16 | 128  128 3  8  16
ok-canon-40D.jpg............................................ 1 | 3888 2592 3  8 | Std     0 | 1 Canon Canon EOS 40D            |  1.63  26.1    0.004  5.0  0.0  200 | 1191078307 | Canon EF 16-35mm f/2.8L II                         | 3888 2592 3  8  16 | 128  128 3  8  16
ok-canon-5D-IMG_6013.JPG.................................... 1 | 2912 4368 3  8 | Fish    0 | 1 Canon Canon EOS 5D             |  1.00  15.0     0.25  6.3  0.0  250 | 1151080624 | Canon EF 15mm f/2.8 Fisheye                        | 2912 4368 3  8  16 | 128  128 3  8  16
ok-canon-5D-sigma12-24mm-IMG_1808.JPG....................... 1 | 2912 4368 3  8 | Std     0 | 1 Canon Canon EOS 5D             |  1.00  22.0        2 16.0  0.0  200 | 1148828499 | Sigma 12-24mm f/4.5-5.6 EX DG Aspherical           | 2912 4368 3  8  16 | 128  128 3  8  16
ok-canon-5D-sigma12-24mm-IMG_1920.JPG....................... 1 | 2912 4368 3  8 | Std     0 | 1 Canon Canon EOS 5D             |  1.00  12.0        2 18.0  0.0  200 | 1148829882 | Sigma 12-24mm f/4.5-5.6 EX DG Aspherical           | 2912 4368 3  8  16 | 128  128 3  8  16
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------