Author Topic: Lens Variable  (Read 9495 times)

Offline csgaraglino

  • Member
  • **
  • Posts: 64
    • View Profile
    • Widow Creek
Lens Variable
« on: September 08, 2009, 07:39:56 AM »
I know there is a variable for the focal length {lens35}, but is there one for the actual Lens (ie. 80-200mm f/2.8 or something)?
Regards,
Chris Sgaraglino
www.WidowCreek.com

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Lens Variable
« Reply #1 on: September 08, 2009, 08:02:47 AM »
Chris,

I know there is a variable for the focal length {lens35}, but is there one for the actual Lens (ie. 80-200mm f/2.8 or something)?

Try {lenstype}

-Kirk

Offline csgaraglino

  • Member
  • **
  • Posts: 64
    • View Profile
    • Widow Creek
Re: Lens Variable
« Reply #2 on: September 08, 2009, 08:20:16 AM »
Perfect, thanks!
Regards,
Chris Sgaraglino
www.WidowCreek.com

dredlew

  • Guest
Re: Lens Variable
« Reply #3 on: May 11, 2016, 09:30:16 PM »
Kirk,

While {lenstype} does sort of provide information, it is incorrect/incomplete. For a Nikkor 28-300, the {lenstype} variable produces "VR Zoom 28-300mm f/3.5-5.6G IF-ED". Not sure where this information is coming from, because the correct information in the Exif is "AF-S Nikkor 28-300mm f/3.5-5.6G ED VR". Every other software I've tried shows this information properly, except PM.

This issue applies to various other lenses as well, at least with Nikon (Sigma does not seem to provide full lens information). I don't see another way of actually retrieving any Exif information in PM other than variables, so I would report this as a bug.

Also not sure why the {lens} variable is representing the focal length of the lens. I would expect {lens} to provide the equivalent information from the Exif, which is that full description mentioned above. Is there a reason why variable names don't map to the Exif info?

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Lens Variable
« Reply #4 on: May 11, 2016, 10:25:28 PM »
While {lenstype} does sort of provide information, it is incorrect/incomplete. For a Nikkor 28-300, the {lenstype} variable produces "VR Zoom 28-300mm f/3.5-5.6G IF-ED". Not sure where this information is coming from, because the correct information in the Exif is "AF-S Nikkor 28-300mm f/3.5-5.6G ED VR". Every other software I've tried shows this information properly, except PM.

The EXIF data you're referring to is really Nikon Maker Note data and the values for the lenses are really just integers (whole numbers) that have various bits set which can be interpreted by software such as Photo Mechanic to produce strings like "VR Zoom 28-300mm f/3.5-5.6G IF-ED".  The string "AF-S Nikkor 28-300mm f/3.5-5.6G ED VR" does not exist in the image at all.

This issue applies to various other lenses as well, at least with Nikon (Sigma does not seem to provide full lens information). I don't see another way of actually retrieving any Exif information in PM other than variables, so I would report this as a bug.

You're welcome to call it a bug, but we would see it as a matter of differences in interpreting bit values in Maker Notes (which are not publicly documented by the manufacturers).
Fortunately, you could use Code Replacement to translate the descriptions PM provides to descriptions more to your liking.

Also not sure why the {lens} variable is representing the focal length of the lens. I would expect {lens} to provide the equivalent information from the Exif, which is that full description mentioned above. Is there a reason why variable names don't map to the Exif info?

It's arbitrary.  The tag value for Nikon lens information is defined as this in our code:

#define NIKON_MAKER_LENS_TYPE_INFO         0x83   // bits for lens type

So in your image file, there is a tag with the ID of 0x83 (hexadecimal) that when read has various bits set.  One bit tells if the lens is AF, another bit tells if it is VR, and so on.  PM then constructs the lens type phrases from these bits of information.

To us {lens} has more to do with the focal length of the lens and {lenstype} gives the lens a name.

-Kirk

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 462
    • View Profile
    • Camera Bits, Inc.
Re: Lens Variable
« Reply #5 on: May 12, 2016, 02:00:38 PM »
#define NIKON_MAKER_LENS_TYPE_INFO         0x83   // bits for lens type

So in your image file, there is a tag with the ID of 0x83 (hexadecimal) that when read has various bits set.  One bit tells if the lens is AF, another bit tells if it is VR, and so on.  PM then constructs the lens type phrases from these bits of information.

Yes PM uses the bits in this Nikon Maker Note tag "LensType" to construct a "lens type" string.  Unfortunately the bits stored in LensType are insufficient to give a definitive description of the lens.  Other manufacturers actually store the "definitive" lens type as a string in their maker note and PM simply copies this.  In order to properly construct the lens type string for Nikon, you have to read 8 different values in the Maker Note and then look them up in this huge table (not just Nikon lenses but Sigma, Tamron, Tokina, Carl Zeiss etc).  We are investigating adding this type of logic.  In the meantime, you can create a code replacement file as Kirk suggested to format the lens type as you wish.  Just create a text file with:

PMLensType {tab} DesiredLensType

(in other words, the string that PM shows, then a single tab character, then the string that you want PM to show instead)

Then load this as a code replacement file.

Then use ={lt}= to convert (assuming that '=' is your code replacement escape) instead of just {lt}.

HTH...

--dennis
« Last Edit: May 12, 2016, 02:10:20 PM by dennis »

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 462
    • View Profile
    • Camera Bits, Inc.
Re: Lens Variable
« Reply #6 on: May 12, 2016, 05:34:41 PM »
More information:

If you visit Phil Harvey's Exiftool site (http://www.sno.phy.queensu.ca/~phil/exiftool/), you will see that Nikon "encrypts" (or obfuscates to be more correct) the lens info data and other metadata in their maker notes. This "encryption" is based on other metadata like serial number and shutter count (meaning every photo is "encrypted" with a different key).

Not only is this a lot of work to deal with the decryption of Nikon's metadata, it is probably a violation of DMCA and we aren't going there even though other large companies (or those entities not making any money) have willingly decrypted this information (Exiftool will actually "re-encrypt" the data if you do something strange like change the serial number).

This is all ludicrous because Exif has a tag 0xA434 which is supposed to allow allow all camera manufacturers a STANDARD (not Maker note) way to record the lens type they are using as a human readable string.  Nikon has chosen to not write this standard string and instead encrypts their lens info.

As proof, if you open your Nikon photo (JPG or NEG) in a binary (hex) editor and simply change the last digit of your serial number (if you can find it) by one digit, then no other application (including Nikon's) will be able to show you your lens type.  This proves the data is "encrypted" and Nikon for some reason does not want to share that info with you, the owner of their camera gear.

Sorry.

--dennis

dredlew

  • Guest
Re: Lens Variable
« Reply #7 on: May 12, 2016, 11:04:40 PM »
Dennis & Kirk,

Appreciate the response and I will try out that workaround, thanks.

In regards to;

Quote
You're welcome to call it a bug, but we would see it as a matter of differences in interpreting bit values in Maker Notes (which are not publicly documented by the manufacturers).

I would disagree here and maybe you missed my mention of the fact that every other photo app I have currently installed (Aperture/Photos/Preview, Affinity Photo, Lightroom, Capture One, PhotoMill) displays the full lens information exactly the same way. PhotoMechanic is the ONLY software displaying it differently. So yes, that is a bug and it does not seem that it is a matter of interpretation, otherwise, all these various other developers would have a different "interpretation" of that data, which is not the case. Maybe the information is not where you expect it to be.

Also, if you upload a RAW file here http://regex.info/exif.cgi (which is based on the Exiftool), you will find that exact lens string returned in the metadata. Apparently, that information is somewhere present in the file in the right format and yet another developer is able to extract it. Your devs really should investigate why they are not able to display what everyone else does.


As for the {lens} variable; again, I'm just not understanding why a focal length value would be called {lens} and not {focalLength}. To me, this is a bug as well. From a user (as well as a dev) perspective, naming needs to make sense. This applies to the majority of these variable names, btw.

Speaking of bugs and UX; there is one more, which is that the variable list is not scrollable with the arrow keys on the keyboard. There is no way to cycle through the list of variables. Each one has to be clicked on with the mouse, in order to find out what the possibly cryptic naming could stand for, i.e. {tv}.

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 462
    • View Profile
    • Camera Bits, Inc.
Re: Lens Variable
« Reply #8 on: May 13, 2016, 11:18:42 AM »
Also, if you upload a RAW file here http://regex.info/exif.cgi (which is based on the Exiftool), you will find that exact lens string returned in the metadata. Apparently, that information is somewhere present in the file in the right format and yet another developer is able to extract it. Your devs really should investigate why they are not able to display what everyone else does.

I am the developer who handles this and I have indeed looked into this string.  This lens type string is NOT stored in the file as a human readable string.  The lens info (8 pieces of information) is "encrypted" by Nikon in a weak fashion based on serial number and actuation count.  When a manufacturer goes to the effort to encrypt something then my understanding is that it is against the law (Digital Millennia Copyright Act) for someone to decrypt this.  Now maybe Nikon really doesn't care or perhaps all these other companies (that are making money) have obtained a release from Nikon.  Until I have clarification on this I am not going to risk it.  Would you risk your company?

A while back Nikon encrypted the white balance for its D2H & D2X cameras which was then promptly broken:

http://www.cnet.com/news/nikons-photo-encryption-reported-broken

Eventually Nikon provided Adobe with a small library that Photoshop linked to which would decrypt the white balance so that Adobe would not have to implement the code themselves.

I will check with Nikon about this and perhaps we can support it in the future.  To be clear, it is not a technological issue but a legal one.  In the meantime, Photo Mechanic provides a workaround.  Of course if Nikon would just use the newer Exif tag 0xA434 to store their lens type string then PM would immediately support it.

As for the {lens} variable; again, I'm just not understanding why a focal length value would be called {lens} and not {focalLength}. To me, this is a bug as well. From a user (as well as a dev) perspective, naming needs to make sense. This applies to the majority of these variable names, btw.

Photo Mechanic has been using {lens} for focal length for 15 years (about 6 years before Lightroom existed).  I guess folks have gotten used to this by now.  BTW The original Exif standard would ONLY store the focal length used for the photo, not the type of lens used (the lens type therefore relegated to the Maker Notes).  This field was labeled "Lens focal length" in the Exif specification which is probably why I called it {lens}.  Since this bothers you so much I will add the variable {focallength} for you in the next build and you are welcome to use that instead of the much shorter {lens} variable.

--dennis

dredlew

  • Guest
Re: Lens Variable
« Reply #9 on: May 14, 2016, 04:07:03 PM »
Alright, that sounds great! Thank you, Dennis!

Offline Ben Curtis

  • Member
  • **
  • Posts: 94
    • View Profile
    • Snappertalk blog
Re: Lens Variable
« Reply #10 on: August 28, 2016, 02:49:37 AM »
Nice, I didn't know about this before.... {lenstype} seems to work perfectly with my Canon lenses.