Canon MakerNotes:lens*

Started by Ppmax, November 26, 2013, 09:28:32 PM

Previous topic - Next topic

Ppmax

Hi

I have a Canon 5D Mark III with a Rokinon MF lens. This Lens does not have a chip. I want to change the maker notes metadata and write the correct lens info for this lens.

I've searched around and realize I can't edit the maker notes metadata directly and have learned that some of the maker notes values are derived from a camera specific lensetype lookup table.

What is the best practice for adding a custom lens and or hacking a .pm file to set these makernote values as I wish? Is this practice documented somewhere? Also, would this best practice procedure work for COMPOSITE tags as well?

If I need to do something in the configuration file, can someone point me to a good tutorial or procedure?

Thx!
PP

Phil Harvey

To write a Composite tag you must write the tags from which it is derived.

But I don't think this is your best option because the maker notes store only a number for the lens type.  Changing this would be very arbitrary since your lens doesn't correspond to any known lens type number.

Instead, I would write the lens model string to EXIF:LensModel.

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

Ppmax

Thanks for the reply Phil--much appreciated.

I have written EXIF data to these files, but it appears my processing application (Apple's Aperture) looks at some other attribute of the file when it displays information about a lens. Here is the exiftool output from one of the files I want to process. As you can see I have set several EXIF tags as desired--however I am not able to write over the MakerNotes or Composite tags:

./exiftool -G -H -lens* ~/Desktop/test/test1.cr2

[MakerNotes]    0x0016 Lens Type                       : Canon EF 35-80mm f/4-5.6
[MakerNotes]    0x0153 Lens Type                       : Canon EF 35-80mm f/4-5.6
[MakerNotes]    0x0095 Lens Model                      : 85mm f/1.4 AS IF
[EXIF]          0xa432 Lens Info                       : 85mm f/1.4
[EXIF]          0xa433 Lens Make                       : Rokinon
[EXIF]          0xa434 Lens Model                      : 85mm f/1.4 AS IF
[EXIF]          0xa435 Lens Serial Number              : 0000000000
[Composite]          - Lens                            : 1.0 - 65535.0 mm
[Composite]          - Lens ID                         : Canon EF 35-80mm f/4-5.6
[Composite]          - Lens                            : 1.0 - 65535.0 mm (35 mm equivalent: 1.0 - 63616.0 mm)


I read up on using the Exiftool_config file, and have created a user defined lens:

@Image::ExifTool::UserDefined::Lenses = (
    'Rokinon 85mm f/1.4 AS IF',
    'Rokinon 14mm f/2.8 ED AS IF UMC',
);


What I'm not clear on is how these user-defined values can be applied to the MakerNotes:LensType attributes or the Composite:LensID attribs. Ideally I'd like to set these tags and/or remove the fake Canon metadata (which is set by an EMF chip).

Thanks much
PP


Ppmax

FWIW, here is the output from another test file:


./exiftool -G -H -e -lens* ~/Desktop/test/test2.cr2
LOADED!
[MakerNotes]    0x0153 Lens Type                       : Unknown (0)
[MakerNotes]    0x0095 Lens Model                      : 14mm f/2.8 ED AS IF UMC
[EXIF]          0xa432 Lens Info                       : 14mm f/2.8
[EXIF]          0xa433 Lens Make                       : Rokinon
[EXIF]          0xa434 Lens Model                      : 14mm f/2.8 ED AS IF UMC
[EXIF]          0xa435 Lens Serial Number              : 0000000000


Also, I understand now that Composite tags are calculated at read-time, so perhaps I don't need to change those...

Is it possible to push the value from EXIF:LensMake into MakerNotes:LensType? Maybe this will get me on my way.

thx
PP

Phil Harvey

As I said, the MakerNotes LensType is a simple number.  You can write it with whatever value you want.  ExifTool converts this to a model name using its list of Canon LensType values.  Since the Rokinon lens doesn't appear in this list, there is no way to get ExifTool to return the name of this lens from the Canon MakerNotes information.  The UserDefined Lenses just allow the user to select the appropriate lens when there are multiple lenses for the same integer LensType value.

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

Ppmax

#5
Thank you again Phil, and Happy Thanksgiving!

I'm sorry you have probably answered that question a thousand times. I'm new to this world and don't yet understand the data model I'm trying to manipulate. Thanks for bearing with me.

I found this thread where it appears you can override the lookup table of maker note lens types by setting a new value for the data at a specific address:
https://exiftool.org/forum/index.php/topic,1850.msg8053.html#msg8053

In it you say:
Quote
I was thinking that you could disable the 0x0016 conversion by overriding
the tag with one of your own.  Something like this:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Canon::CameraSettings' => {
        0x0016 => {
            Name => 'MyLensType',
        },
    },
);


If my application (Aperture) is reading values at specific addresses, can I set something like this up and get what I want? I would then need to add a custom number to the lens type lookup table?

Thanks again for your help and patience ;)

PP

Phil Harvey

If Aperture reads the LensType number from this location in the maker notes, then it is only the number that matters, and not any string returned by ExifTool (user defined or otherwise).  For example, to set the numerical value to 0, you would do this:

exiftool -lenstype#=0 image.jpg

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

Ppmax

#7
Thanks again--

Through a combination of experimentation and head banging it appears I've solved my issue. To get the proper lens value to show up in Aperture I do this:
exiftool -lenstype#=0 -lensmodel='Rokinon 14mm f/2.8 ED AS IF UMC' [...on a bunch of files]
touch [filename]


What I'd really like to do is run exiftool with the if switch, then run a shell script on the matches. Is there some way to get the absolute file path out of exiftool? Ultimately I'd like to do something like:
exiftool -absoluteFilePath -if '$lenstype=~/unknown/i' . > listOfFiles.txt  //this file would contain the abs path to file, 1 per line

How can I get the absolute path to an image out of exiftool?

Thanks again for all your help Phil--

PP


Edit: edited formatting

Ppmax

Found this in the forums--this works great:
exiftool -p '$directory/$filename' -if '$lenstype=~/unknown/i' `pwd`

Now I'm cooking with gas!

PP

Phil Harvey

I love it when people answer their own questions. :)

Looks good.

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

Ppmax

Yeah, sorry for all the newbie questions...there's that stage when you're just learning the ropes where you don't know the vernacular, how it works, etc...I think I've got the gist of using your tool now...

I am rethinking my post processing strategy...after setting attribs on my .CR2 files I need to touch them to force a refresh in Aperture. For safety's sake I think I'll use something like:
exiftool -p '$directory/$filename' -if '$lenstype=~/unknown/i' `pwd` > ~/Desktop/2013-unknown.txt
...to generate a list of files for processing, then write a shell script to call exiftool again to set attribs, etc. For safety I'll probably cp each file to another dir rather than using -overwrite_original_in_place. Finally I'll touch each file.

I'm sure I could do this in a one liner, but I'd probably foobar a bunch of originals by fat fingering something in the command ;)

Have a nice day
PP

Phil Harvey

One thing:  I don't see why the "touch" is necessary.  ExifTool will update a file's modification date when it writes it (unless you use the -P option).

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

Ppmax

QuoteOne thing:  I don't see why the "touch" is necessary.  ExifTool will update a file's modification date when it writes it (unless you use the -P option).

This may be particular to Aperture. I read about it in another forum. I tried a few tests without using touch and the file metadata is not updated in Aperture after running exiftool. However, using touch forced an update and everything refreshes in the metadata display panel. Go figure.

PP

Ppmax

Just wanted to say thanks again for the help Phil.

I downloaded your tool just the other day, and after a few questions asked and nicely answered, today I was able to search through about 20K images (-if EXP) to find a small subset of pics with very specific (incorrect) lens data, generate a list of files containing paths to these files, pass this list of files through a little bash script that calls exiftool again, juggles some metadata around, and finally overwrites all the originals (-overwrite_original_in_place) with nary a hitch and no trace of ever having been done.

With this under my belt I've decided to build some custom import scripts that will execute when I copy images from camera to computer, so that all new files are renamed by DateTimeOriginal, scanned for incorrect lens data (will only happen with two of the MF lenses I own), and fixed accordingly.

This tool has also prompted me to read up on bash shell scripting and creating custom flags and parameters to pass into these scripts. So your tool has not only provided a practical solution, but has also fomented a revived interest in shell scripting.

+============+
+\\ Fantastic Tool! //+
+============+


thx--
PP