Jump to content

Changing lens info in EXIF


Recommended Posts

Advertisement (gone after registration)

Having several uncoded lenses, I now and then forget to change lens info maually in the meny. The wrong lens info is then registered in the EXIF file and the wrong lens info shows up in LR.

Is there any way to change this in LR or is there some simple program to do this?

Is there any of the do-it-yourself coding system being any good?

Link to post
Share on other sites

I'd also be interested in an answer for this one - I can't see a way of doing it in LR - and I've not worked out if there's a way of doing it as a batch process in PhotoMe. Advice gratefully received - Best would be if there was a way of adding the lens information to exif when ingesting files through Lightroom...

Link to post
Share on other sites

In PhotoMe you can change "Lens focal length" and "Focal length in 35 mm film".

 

In Lightroom the lens info is shown as t.ex. "Leica Summicron-M 35mm f/2 ASPH"

Where is this info hidden in the EXIF and how could one change it to t.ex. "Leica Elmarit-M 28mm f/2.8" if you have used this lens without manually changing in the menu?

Link to post
Share on other sites

The OP asked for a method in LR, so clearly the best would be if you could do it in LR. However, until someone can show a LR-native method, there are many tools available for this, but I recommend ExifTool by Phil Harvey because it is extremely powerful, flexible and available for many platforms. It doesn't hurt that it carries a very good reputation and that it is free ;)

 

It can be used for single image editing or batch processing.

 

Regards

Per

  • Like 1
Link to post
Share on other sites

The OP asked for a method in LR, so clearly the best would be if you could do it in LR. However, until someone can show a LR-native method, there are many tools available for this, but I recommend ExifTool by Phil Harvey because it is extremely powerful, flexible and available for many platforms. It doesn't hurt that it carries a very good reputation and that it is free ;)

 

It can be used for single image editing or batch processing.

 

Regards

Per

 

Downloaded it.....but I must be just too dumb.....can't find out how to use it :confused:

Link to post
Share on other sites

In PhotoMe you can change "Lens focal length" and "Focal length in 35 mm film".

Both are standard fields defined in the EXIF standard. The lens type info is not.

 

In Lightroom the lens info is shown as t.ex. "Leica Summicron-M 35mm f/2 ASPH"

Where is this info hidden in the EXIF and how could one change it to t.ex. "Leica Elmarit-M 28mm f/2.8" if you have used this lens without manually changing in the menu?

Leica’s extensions to the EXIF standard (the MakerNotes) have been extensively documented by Carl Bretteville (the m8 metadata project). The data on lens ID and frame selector position is identified by a 0310h tag value and is stored as an unsiged 32 bit integer. Of the least significant byte, the upper 6 bits encode the lens ID; the Elmarit-M 28 mm f/2.8 would be encoded as 011011, for example.

  • Like 2
Link to post
Share on other sites

Advertisement (gone after registration)

Downloaded it.....but I must be just too dumb.....can't find out how to use it :confused:

 

The easiest is of course if you have a friend who can give you a live demonstration. Otherwise I'm afraid you will actually have to read the instructions on the web page, including useful links ;)

 

If you scroll down a bit under the headline "Related Utilities" you can find links to various GUI addons that may get you started quicker.

 

Regards

Per

  • Like 1
Link to post
Share on other sites

How to use Phil Harvey's ExifTool to to set or reset the lens info in the metadata of Leica M image files

 

 

To set the lens info to Summarit-M 35 mm 1:2.5, for example, type this on the command line:

exiftool -n -MakerNotes:LensType="43 2" -XMP:MaxApertureValue=2.5 -EXIF:MaxApertureValue=2.5 -EXIF:FocalLength=35 -EXIF:FocalLengthIn35mmFormat=35 <image file 1> <image file 2> ...

Alternatively, create a plain text file named 'summarit35.txt' with this content:

-n
-MakerNotes:LensType=43 2
-XMP:MaxApertureValue=2.5
-EXIF:MaxApertureValue=2.5
-EXIF:FocalLength=35
-EXIF:FocalLengthIn35mmFormat=35

Then type this on the command line:

exiftool -@ summarit35.txt <image file 1> <image file 2> ...

Note that the two LensType numbers are enclosed in double quotes on the command line but aren't in the argument file. You can also include the list of image file names in the argument file—one file name per line—and then just type:

exiftool -@ summarit35.txt

In the file names, you can also use wildcards, for example *.jpg will process all JPEG files in the current folder. You can specify JPEG and DNG files, and you can also mix these in one single command.

 

The LensType is two numbers, separated with a blank. The first number is the 6-bit lens code; the second number is the 2-bit frameline code (1 = 28/90; 2 = 35/135, 3 = 50/75). For lenses shorter than 28 mm, see what framelines the camera brings up, then use the respective frameline code for that lens. As an exception to this rule, use the frameline code 0 for the following lenses:

 

  • Summilux 35 mm 1:1.4 (LensType = 6 0)
  • Noctilux 50 mm 1:1.2 (LensType = 31 0)
  • Tele-Elmar 135 mm 1:4 (LensType = 39 0)
  • Apo-Telyt 135 mm 1:3.4 (LensType = 9 0)

 

For the Tri-Elmar 28-35-50, use the frameline code that matches the focal length setting. For the Tri-Elmar 16-18-21, use 1 for 16 mm, 2 for 18 mm, or 3 for 21 mm.

 

This procedure will enter the lens info but leave the aperture data blank. When no lens is recognized then the APEX aperture value 0 will be stored in the metadata which represents aperture f/1. Changing this is surprisingly complex ... but can be done with ExifTool if you really are committed to.

Edited by 01af
  • Like 2
Link to post
Share on other sites

O1af - many thanks for this - it works for the Apo Telyt 135, but it also makes me ask myself if I really need the exif data! :)

 

What I still really want is clearly the possibility to code my lens so that the M9 recognises it - this I fear is something that Leica just doesn't want to give me... Why, I'll never understand. :eek:

Link to post
Share on other sites

Thanks! This is exactly what I have been looking for. Using AppleScript I created a Mac application onto which I can drop any number of files to change their EXIF to my one uncoded lens. If there is interest I can post a recipe how to do that.

Link to post
Share on other sites

Using AppleScript I created a Mac application onto which I can drop any number of files to change their EXIF to my one uncoded lens.

In Windows XP (and most likely in the other Windows flavours as well) you can achieve the very same without even writing a script.

 

Download the ExifTool executable for Windows from Phil Harvey's website, unzip it, rename the executable file from "exiftool(-k).exe" to "exiftool.exe" and place it in an arbitrary folder on your harddisk ... for example in C:\Program Files\ExifTool\. Create an argument file for your uncoded lens as outlined above and place it in the same folder, alongside exiftool.exe.

 

Now right-click on exiftool.exe and from the context menu popping up, select "Create Shortcut". A new file named "Shortcut to exiftool.exe" will emerge. Grab it and drag it to the desktop. Rename it at your convenience. Right-click on it and select "Properties". In the dialog box popping up, locate the line labelled "Target". It should read "<yourfolder>\exiftool.exe" (here, <yourfolder> is a placeholder for the folder you have placed exiftool.exe in, that is, for example, "C:\Program Files\ExifTool"). To this line, append this: " -@ <argument file>", where <argument file> is the name of your text file holding the ExifTool arguments to set your lens' metadata. So for exiftool.exe placed in C:\Program Files\ExifTool\ and for the lens Apo-Telyt-M 135 mm 1:3.4, for example, the Target line should read:

C:\Program Files\ExifTool\exiftool.exe -@ apotelyt135.txt

Click OK to close the Properties dialog box. Now you can select one or many image files in Windows Explorer, drag them to the ExifTool shortcut icon on your desktop, and drop them there. However do not select too many files at once, or the drag-and-drop operation will fail.

 

ExifTool will back up the image files and append "_original" to their names before writing any changes to the metadata. To suppress this, you can add the argument "-overwrite_original_in_place" to your argument file. However, if you do that then it will a good idea to have a backup of your image files somewhere (that would be a good idea anyway). Usually, ExifTool is working very reliably—but you know what they say ... shit happens.

 

If you have more than one uncoded lens then you'll need several shortcuts to exiftool.exe with distinct names, and several argument files accordingly.

 

If you are familiar with scripting then you can always create argument files dynamically and then issue a system call of the form "exiftool -@ <arg file>" to perform all kinds of sophisticated metadata manipulation. Works great for example with Bridge scripts.

Edited by 01af
  • Like 1
Link to post
Share on other sites

01af

 

Many thanks, this looks very useful esp. for my 90/2.8 tele-elmarit files before I had it coded.

 

Can you point me in the right direction for the values in the 'teleelmarit90fat.txt' file? Note it should be appropriate for M8 or does that not make any difference?

 

-n

-MakerNotes:LensType=43 2 (what should I use here? I believe there is a comprehensive list somewhere for M9, is it the same for M8?

-XMP:MaxApertureValue=2.8

-EXIF:MaxApertureValue=2.8

-EXIF:FocalLength=35 Q: should this be 90 or 1.33x90?

-EXIF:FocalLengthIn35mmFormat=90

 

TIA

Stephen

Link to post
Share on other sites

Can you point me in the right direction for the values in the 'teleelmarit90fat.txt' file? Note it should be appropriate for M8 or does that not make any difference?

It does make a difference in the FocalLengthIn35mmFormat tag only. The 6-bit lens codes are the same for M8 and M9 cameras, however the 2-bit frameline codes are not. On the M8 & M8.2, the frameline code 2 stands for 24/35 rather than 35/135. So your argument file would look like this:

# ExifTool argument file
# Adds lens info for Tele-Elmarit-M 90 mm 1:2.8 on Leica M8 camera

-n
-MakerNotes:LensType=4 1
-XMP:MaxApertureValue=2.8
-EXIF:MaxApertureValue=2.8
-EXIF:FocalLength=90
-EXIF:FocalLengthIn35mmFormat=120
-overwrite_original_in_place

The first two lines are just a comment; you may just as well skip them. ExifTool ignores blank lines and lines starting with a # character. But it may be useful for future reference. Remove the last line if you want ExifTool to back up your original image files before tampering with them.

Edited by 01af
  • Like 1
Link to post
Share on other sites

Thanks! This is exactly what I have been looking for. Using AppleScript I created a Mac application onto which I can drop any number of files to change their EXIF to my one uncoded lens. If there is interest I can post a recipe how to do that.

 

Hey Roey,

 

Can you please explain how you do that?

 

Thanks!

Link to post
Share on other sites

Here are the instructions how to create droppable Exiftool applications for the Macintosh using AppleScript.

 

Disclaimer: Like all software the script posted below or the Exiftool software may contain bugs that could cause you to lose files. They work for me, but I don't take any responsibility for what they are doing on your computer.

 

With that said:

 

The idea behind this droppable applications is that you create one per lens. You can keep them on your desktop or in your dock and simply drop image files that you want to change onto the application icon. The application immediately starts to process the files — it doesn't ask for confirmation, so if you have multiple apps you'll want to make sure to drop the files onto the correct one.

 

1. Download and install Exiftool (link posted earlier in this thread)

 

2. Launch AppleScript Editor (should be in the Utilities folder within your Applications folder)

 

3. AppleScript Editor should open a new Untitled script window in which you paste the following script:

 

on open fileList
-- specify the lens
-- change the numbers in quotes to your specific lens
set lensCode to "38" -- the 6-bit lens code
set frameSelector to "1" -- the 2-bit frameline code (1 = 28/90, 2 = 35/135, 3 = 50/75)
set maxAperture to "2.8"
set focalLength to "90"
set focalLength35mm to "90" -- set this to folcal length x 1.3 for M8
-- option for deleting the original image
-- change this from false to true if you are sure that everything is working and you don't want to preserve the original file
set deleteOriginal to false

-- get list of quoted paths for the files that were dropped onto the script
set filePaths to {}
repeat with f in fileList
	set filePaths to filePaths & quoted form of (POSIX path of f)
end repeat

-- convert to a space separated string that we can use in the shell script
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
set filePaths to filePaths as text
set AppleScript's text item delimiters to old_delim

-- construct the shell script
set scrpt to "exiftool -n"
if deleteOriginal then
	set scrpt to scrpt & " -overwrite_original"
end if
set scrpt to scrpt & " -MakerNotes:LensType='" & lensCode & " " & frameSelector & "'"
set scrpt to scrpt & " -XMP:MaxApertureValue=" & maxAperture & " -EXIF:MaxApertureValue=" & maxAperture
set scrpt to scrpt & " -EXIF:FocalLength=" & focalLength & " -EXIF:FocalLengthIn35mmFormat=" & focalLength35mm
set scrpt to scrpt & " " & filePaths

-- run the script
do shell script scrpt
end open

 

4. Click the Run button in the top of the window. Don't worry, with this scrip this will actually do nothing but check its syntax. If you get an error message it means that something went wrong with the copy/paste. Try it again and make sure that you copy all the text. If everything is OK with the script you should see its text getting styled with different colors.

 

5. The first quarter of the script contains some definitions (set XXX to "YYY") that you will want to edit in order to describe your lens by changing the YYY part. Make sure that you don't accidentally delete the opening or closing quotes.

 

6. Click the Run button again. If you see an error message at this stage it means that something went wrong in step 5. If you can't figure out what, you may want to start over.

 

7. Choose Save As from the File menu. You will want to make sure to give your app a descriptive name, to choose Application from the File Format list, and to make sure that all three checkboxes are unchecked. It should look like this:

 

 

 

8. Try it out. Drop an image onto it in the Finder. If you are using Lightroom you will want to choose Read Metadata from File from the Metadata menu to verify that the script worked.

 

The script preserves the original image files by appending .original to their names. If you don't want that (and if you are sure that you have done everything correctly) you can modify the script by opening it in AppleScript Editor and changing the line

 

set deleteOriginal to false

 

to

 

set deleteOriginal to true

 

and then saving the script.

 

Let me know if you are running into any issues.

  • Like 3
Link to post
Share on other sites

I put together another AppleScript that uses ExifTool to update the Exif info.

This script is like roey's excellent script except that no editing of the code is needed.

To use it:

Just drop files, or folders of files, or folders of folders onto the Applescript.

the user then selects their lens from a list

the user then selects whether they want the original files overwritten

The Script automatically sets the Lens Code, FrameLine Code, Max Aperture, Focal Length, Crop factor etc. I got the Lens Codes from Carsten's Site. For files with a M8 Camera Model the FocalLengthin35mmFormat is increased by the crop factor (1.3).

 

Caveat: I have tested this script with my M9 photos and with some M8 photos that I downloaded from this forum, using ExifTool 8.28. I suggest you test this script on copies of your photographs before you trust it. I have only tried this on M8 and M9 photos. Use at your own risk.

 

One interesting quirk was that I could not set the EXIF:MaxApertureValue to less than 1.0.

I emailed Phil Harvey the author of ExifTool and this was his reply:

 

Hi Roy,

This is a deficiency of the EXIF specification. The value stored is

the APEX value, which is negative for apertures wider than 1.0. But

the EXIF specification restricts this value to be unsigned, so

negative values are not allowed.

- Phil

 

You can download SetLeicaExif.app here.

Also on the page is a script written by Rob Lewis "List Exif Metadata" to view the EXIF values. The apps are zipped.

Comments and suggestions for improvement are welcome.

  • Like 1
Link to post
Share on other sites

  • 1 year later...

Exif Tool is a great application, but it requires you to be familiar with the Terminal command line environment.

 

If you use a Mac there's a small application on the App Store called EXIF EDITOR that adds a graphical front end to Exif Tool and makes it really easy to use. Allows you to make presets for each of your lenses and to select and process multiple files. Can't remember how much it is but I thinks its less than $10.00.

 

If you use Aperture which doesn't transfer all of the Leica maker file info to the Exif, it also allows you to add the lens type and focal length.

 

Hope that's helpful :)

Edited by Bobitybob
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...