Hi, I could use a little guidance. I'll start with a statement of the problem before I get to my questions in case I am way off in the weeds here with the direction I'm taking.
Problem:
* I would like for my custom optics that I attach to my DSLR to have proper identification in Lightroom/PS/ACR, which should persist as far down the image processing chain as can be managed based on the support of that other software.
* The difficulty in accomplishing the above lies partly in the sorry state of affairs with Sony Alpha lens chips. Ask for a 1000mm f/5.9 for a fixed-aperture telescope and wind up with a lens that reports itself as a 1000mm "100mm MACRO f/2.8" with a max aperture of "f/1.0" that shot at f/5.6. Ask for a 35mm f/4 and wind up with a lens that reports itself as a 35mm "100mm MACRO f/2.8" with a max aperture of "f/1.0" that shot at f/1.4. These both have the same LensID value reported by ExifTool and came from the same supplier BTW.
* Add to the above I actually have a Minolta 100mm macro that rightly uses the same ID, so any processing has to avoid files actually made with this lens.
* The first lens above should report its FL as 1200mm, its max aperture as f/5.9 and the shooting aperture as f/5.9, and should have a description like "telescope".
* The second lens above should report its FL as 35mm with a max aperture of f/3.5 and I'll settle for reporting a shooting aperture of f/3.5 by default though the aperture is adjustable.
Inspiration:
* Jeffrey Friedl's excellent GPS data injector plugin for LightRoom, which leverages ExifTool and shows that such things are possible.
* Nothing out there seems to do quite what I want. Except maybe ExifTool, if I build a custom solution. Yes, I've looked carefully at AlphaLensInfo but it can't deal with two or more lenses having same ID/different focal length, at least not in one pass.
* I can do it.
I'm well on my way. I have a Perl script that goes out and finds all of the XMP files that contain any of the lens IDs listed in a local %LensIDMap configuration/translation hash with:
$id = $image_info->{'LensID'};
$focal_length = $image_info->{'FocalLength'};
_get_left_of_decimal($focal_length); # Decruft returned values like "1200.0 mm"
if ( $LensID->{$focal_length}->{$id} ) { # More processing };
This is the beginnings of the configuration hash being accessed, I expect this may grow over time... as it is, I have several entries that need to be added:
$LensIDMap = (
"1000" => {
"25811" => {
"Aperture" => "5.6",
"NewAperture" => "5.9",
"NewID" => "26051",
"NewDescr" => "Orion XT8 Dobsonian Telescope",
"NewFL" => "1200"
}
},
"35" => {
"25811" => {
"Aperture" => "1.4",
"NewAperture" => "3.5",
"NewID" => "25221",
"NewDescr" => "Mamiya 35mm f/4 Sekor-N on Mirex Tilt/Shift",
"NewFL" => "35"
}
},
50 => {
25621 => {
"Enabled" => "1",
"MaxAperture" => "2.8",
"NewAperture" => "8",
"NewID" => "25221",
"NewDescr" => "Contax/Zeiss 135mm f/2.8",
"NewFL" => "135"
},
25501 => {
"Enabled" => "1",
"MaxAperture" => "4",
"NewAperture" => "4",
"NewID" => "25501",
"NewDescr" => "Macro Bellows",
"NewFL" => "50"
}
},
);
Now, my intent is to take the data in the hash at $LensIDMap->{$focal_length}->{$id} and feed it to ExifTool to update my .XMP files, but the XMP seems to be a morass of seemingly duplicate and sometimes arcane info. For example there is <exif:FNumber>, <exif:ApertureValue>, <exif:FocalLength>, <exif:FocalLengthIn35mmFilm>, and the non-duplicated <exif:MaxApertureValue>. Often these have strange values that nevertheless seem to be interpreted well enough by LR... some examples:
<exif:MaxApertureValue>497/100</exif:MaxApertureValue>
<exif:FNumber>56/10</exif:FNumber>
<exif:ApertureValue>4970854/1000000</exif:ApertureValue>
<exif:FocalLength>12000/10</exif:FocalLength>
Now, if I pass in for example 'ApertureValue' using the correct value, e.g. f/5.9, will ExifTool automatically convert to the arcane fraction notation? Or do I have to come up with that fraction(which is apparently never an exact match for the real value)? And will ExifTool automagically populate FNumber when I set ApertureValue or do I have to handle that myself? Similar question for FL, do I need to pass that in as a fraction, will ExifTool convert it, does it matter? Do I need to add ".0 mm" back to the FL value before asking ExifTool to write back to XMP?
The above questions relate in part to manipulations ExifTool may perform on the passed values but also to whether LR/PS will freak out if it sees these expressed as integer or floating point instead of fraction.
Below is some of the relevant output from ImageInfo():
$image_info HASH(0x32bee54)...
'Aperture' 5.6
'ApertureValue' 5.6
'CreatorTool' 'DSLR-A900 v2.00'
'FNumber' 5.6
'FOV' '2.1 deg'
'FileName' 'DSC07857.xmp'
'FileType' 'XMP'
'FocalLength' '1000.0 mm'
'FocalLength35efl' '1000.0 mm (35 mm equivalent: 1000.0 mm)'
'FocalLengthIn35mmFormat' '1000 mm'
'HyperfocalDistance' '5943.22 m'
'Lens' 'MACRO 100mm F2.8'
'LensID' 25811
'LensInfo' '100mm f/2.8'
'MaxApertureValue' 1.4
'RawFileName' 'DSC07857.ARW'
I'm on vacation right now and haven't read through your post in detail, but I think that ExifTool already has the logic to do what you want, and should work provided that all lenses have been defined. The only problem is that I don't have a user-defined way of adding new lenses, and it sounds like that is what you need. You could edit the appropriate module (Minolta.pm) and add your lenses. I know this isn't an ideal solution but I thought I'd just throw it out there.
- Phil
I've combed through Minolta.pm and more, as far as I can tell focal length, max aperture and ID are straight decodes of the info on the chip, and the problem lies in having more than one focal length/max aperture for a given lens ID, as well as a different description. So far as I can tell %minoltaLensTypes entries and the guesses made based on focal length are not going to get me there. I have a number of different lenses that end up with the same ID even though the adapters indicate different focal lengths. I want to sort this out.
For example, here are the lenses/adapters that have ID 25811:
1000 f/1 => 1200 f/5.9 shot at f/5.9 (fixed aperture)
80 f/1 shot at f/1.4 => 80 f/4 shot at f/'n' (user-settable, different part of the problem)
100 f/2.8 => Leave this one alone, it really is 25811.
I typed it out like a hash, keys are what's reported by the chip and values are what I want in the XMP.
For now, I hope you enjoy your vacation. When you have time to get back to this, the real meat of the question starts right after I show %LensIDMap. It seems that understanding how ValueConv and ValueConvInv(in Minolta.pm) play a part might help me -- or not. It seems that some of the values I'm concerned with may be multiplied or divided by 256 but the math doesn't seem to work out either way when I compare XMP values vs camera settings as set or as reported by LR.
Also the question as to whether I should set e.g. three aperture entries separately or if ExifTool will propagate to e.g. "Aperture", "ApertureValue", and "FNumber" with a single call.
Another puzzling tag is "FOV". Will ExifTool recalculate this if I enter a different focal length, or should I do that? And is it diagonal FOV or one of x or y axis?
I should probably experiment to get some of these answers... I just thought I'd ask if there is some level of automation in ExifTool that will help with the heavy lifting. :)
Nothing's on fire at the moment, this is a spare time project so no big rush. :)
Quote from: Dave_Anderson on April 27, 2011, 02:06:13 AM
I've combed through Minolta.pm and more, as far as I can tell focal length, max aperture and ID are straight decodes of the info on the chip, and the problem lies in having more than one focal length/max aperture for a given lens ID, as well as a different description. So far as I can tell %minoltaLensTypes entries and the guesses made based on focal length are not going to get me there.
I don't understand why not. But then again I don't know what information your camera reports for these lenses. Ambiguous LensType values are differentiated in the logic of the Composite LensID tag based on reported FocalLength, ApertureValue, etc (See the Composite LensID documentation). If these are reported correctly, then ExifTool should be able to identify the lens.
- Phil
Sorry, I misspoke. I realize that for a given LensID ExifTool can perform some disambiguation for two chips based on focal length, presumably by matching the focal length(s) in the description. What i see as difficult cases are the following(a sample):
- For the ID mentioned above, how can ExifTool disambiguate a chip that reports itself as 1000mm when I want the description to say 1200mm?
- How does ExifTool determine which chip is which when both report the same LensID and Focal Length, only differing in the max aperture supported?
- If the MaxAperture value is used in disambiguation, where do I tell it that this particular lens reported as an 80 f/1.4 with a description of "80mm f/4" needs to have the MaxAperture tag changed to f/4?
- Any other case where the data reported by the adapter is just plain wrong, so matching 1:1 on anything it reports is the wrong thing to do.
In any event I want to be able to bypass the guesswork in many instances so I need to dig deeper anyway. I want the script user (me initially, perhaps others later) to be able to override what is in the EXIF and ExifTool's guesses at will. For example a chip that may report that the camera had set aperture f/'n' may need to be corrected to show that the shot was taken at that lens's fixed aperture, not whatever the camera setting was. Flip side, some adapters may always report the same f/number even though a different setting was used on the shot. Or the user may want to enter specifics for an unchipped adapter that is use for many lenses, and do so with a UI (planned but outside the scope of the discussion) instead of editing Minolata.pm perhaps several times for the photos in one shoot.
BTW the closest thing I could find to a reference on Composite LensID is at the bottom of http://www.exiftool.org/config.html. Would you mind nudging me in the right direction?
Thanks,
Dave
Hi Dave,
Quote from: Dave_Anderson on April 28, 2011, 03:32:27 AM
For the ID mentioned above, how can ExifTool disambiguate a chip that reports itself as 1000mm when I want the description to say 1200mm?
Right. This is a problem that isn't covered by the current logic.
QuoteHow does ExifTool determine which chip is which when both report the same LensID and Focal Length, only differing in the max aperture supported?
This should be fine as long as the images report the correct max aperture because this is covered by the ExifTool logic.
QuoteIf the MaxAperture value is used in disambiguation, where do I tell it that this particular lens reported as an 80 f/1.4 with a description of "80mm f/4" needs to have the MaxAperture tag changed to f/4?
Again, this is a problem if the MaxAperture is reported incorrectly. :(
QuoteAny other case where the data reported by the adapter is just plain wrong, so matching 1:1 on anything it reports is the wrong thing to do.
I think I understand better now, thanks.
Yes. The ExifTool logic doesn't help here.
QuoteBTW the closest thing I could find to a reference on Composite LensID is at the bottom of http://www.exiftool.org/config.html. Would you mind nudging me in the right direction?
See the Composite tag name documentation (https://exiftool.org/TagNames/Composite.html)
You will note there are a few different LensID tags which handle specific cases for various makers. Also see the PrintLensID() function in Exif.pm if you want to look at the source code.
- Phil
Thanks Phil.
Back to my unanswered questions above, I guess I can infer that the Coposite Tags only work one way, e.g. I'll have to update aperture and FL values individually -- there is no catch-all to, for example, set one aperture field and have the rest of the aperture fields populated. OK, no problem.
The other question that is still open is about the arcane fractional notation for aperture and FL values. Do I need to update those using the fraction notation or can I just enter a value e.g. 5.9 for aperture or 1200 for FL? do I need to append mm to FL or will ExifTool handle that?
What is confusing me about the fraction notation is the math doesn't work out. For example 497/100 displays as f/5.6. What algorithm is used for conversion?
Hi Dave,
Quote from: Dave_Anderson on May 02, 2011, 01:48:22 PM
Back to my unanswered questions above, I guess I can infer that the Coposite Tags only work one way, e.g. I'll have to update aperture and FL values individually -- there is no catch-all to, for example, set one aperture field and have the rest of the aperture fields populated.
Right.
QuoteThe other question that is still open is about the arcane fractional notation for aperture and FL values. Do I need to update those using the fraction notation or can I just enter a value e.g. 5.9 for aperture or 1200 for FL? do I need to append mm to FL or will ExifTool handle that?
In general, you write values using the same syntax as when they are extracted. But exiftool is often very forgiving, and will accept many variations. Just try it to see what works.
Quote
What is confusing me about the fraction notation is the math doesn't work out. For example 497/100 displays as f/5.6. What algorithm is used for conversion?
ExifTool converts FNumber and ApertureValue to the same units, although ApertureValue is stored internally as an APEX value, but you don't need to worry about this because ExifTool does the conversion.
- Phil