ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: roxie380 on December 04, 2012, 05:17:39 PM

Title: Canon Lens Serial Number string
Post by: roxie380 on December 04, 2012, 05:17:39 PM
Phil,

Do you know what data string the tool is reading when it present "Lens Serial Number?"  When I look at "All" data with the GUI, I do see a Lens Serial Number but it appears to be some sort of HEX data.  I've tried using a converter but the decimal data does not come anywhere near the lens serial number.

I know this may have been discussed before but the tool is reading some string, and it does change with the lens.  I had two copies of the Canon 24-105 and each one gave a different entry in the Lens Serial Number field.  For example, Lens (21)0454585 produces 0004269a5 and lens (21) 03735253 shows 0001c0f94.  Its the same lens type so we must be reading some data; I just can't figure out what.

Thanks for looking at this.
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 05, 2012, 07:27:03 AM
If you consult the Canon tag name documentation (https://exiftool.org/TagNames/Canon.html), you should find your answer.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 05, 2012, 07:49:44 AM
Phil,

I looked at the Canon Tags reference you supplied and I'm still puzzled.  Maybe I just don't know what you wanted me to see.  If the Lens Serial Number is actually in the EXIF data, and I'm seeing a string, be it hex or some other format, how does it convert to the actual lens serial number in true decimal?  I've tried every conversion I can think of ........ what am I missing?

Sorry to seem so dense.

Thanks
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 05, 2012, 07:56:53 AM
Did you see this?:



0LensSerialNumberundef[5](apparently this is an internal serial number because it doesn't correspond to the one printed on the lens)

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 05, 2012, 08:05:28 AM
Phil,

I had not seen that - I don't have much experience reading these Canon tag tables and sub-linked tables.

Is that the string that EXIT Tool is presenting when it shows "All" Lens Serial Number?

Do I understand there is no direct relationship to the real (printed) serial number?  If this internal number is constant, could I make a manual cross-reference chart, or is there a way to do that in the tool?

Thanks for sticking with me on this!
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 05, 2012, 08:37:28 AM
Quote from: roxie380 on December 05, 2012, 08:05:28 AM
Is that the string that EXIT Tool is presenting when it shows "All" Lens Serial Number?

I can't say.  Use the -G1 option, and if the group is "Canon", then the answer is yes.

QuoteDo I understand there is no direct relationship to the real (printed) serial number?  If this internal number is constant, could I make a manual cross-reference chart, or is there a way to do that in the tool?

You could do the cross-reference with a user-defined Composite tag if you want, with a PrintConv that converts from internal to external serial number.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 05, 2012, 09:26:26 AM
WOW - thanks.

Too bad Bogdan isn't supporting the GUI any more.  What you suggested is probably way beyond my understanding.

Thanks for the information ----- and the continued support of the tool.  It takes a lot of work, but I want you to know its very much appreciated.
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 05, 2012, 06:04:36 PM
Phil,

Well, the mystery continues.  I ran the tool with the following  "exiftool -k -g1 1.jpg" and the Lens Serial Number appears in the line just before the Canon grouping.  The last three lines before the Canon grouping are: Lens Info, Lens Model, Lens Serial Number.

So, I don't think this is coming from the Maker notes.

Also, in the GUI run, the Lens Serial number does not show when I select "Maker" - it does appear in "Exif" and "All" but not "Maker."

I would have thought you were right based on the Canon tag data, but this is getting strange.  The tool is reading the data - just don't know where.

Any suggestions?




Thanks
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 05, 2012, 07:04:34 PM
OK, more information would be useful at this point.  What camera model, and did you edit the JPEG with any other software?

- Phil

edit: Of course a sample image would answer all questions.  You can email it to philharvey66 at gmail.com
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 08:28:10 AM
Phil,

I have Canon EOS 5D MK III.  The images are straight out of the camera, right from the card and it makes no difference if they are jpeg or CR2 files.  If you want I can send you one jpeg to read the data if you wish.

At one point I was sure I was seeing this on the Canon 7D, too, but can't see it now.

Thanks
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 09:07:03 AM
This is helpful, thanks.

My 5DmkIII CR2 and JPG samples have an ExifIFD:LensSerialNumber.  This is an ASCII string written by the camera in the standard EXIF metadata.  It isn't in the Canon maker notes as with some other models.

However, in my 5DmkIII MOV video sample, there are 2 LensSerialNumber tags.  One in the ExifIFD, and one in the Canon MakerNotes.  Both have the same value, and I'm guessing that neither corresponds to the printed serial number on the lens itself.

- Phil

Edit:  I just checked my 7D samples.  Firmware 3.7.5 (pre-production) didn't write a LensSerialNumber.  Firmware 1.0.8 writes LensSerialNumber in the MakerNotes.
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 09:40:17 AM
Phil,

Gotta love the manufactures.  Was what you saw on the 7D called "internal serial number?"  I just checked some of my older images - firmware version 1.0.8 did, 1.2.3 did, 1.25 did, but firmware 2.0.0 and the  current firmware firmware does not show the "internal serial number."

And, now we know the lastest version of the 5D MK III does show "Lens Serial Number."  Guess its like "stay tuned for the lastest change!"

You say this is an ASCII string.  Guess I was confused when I saw it had "letters" and thought hexidecimal.

Since it is constant, you mentioned a way to build a cross-reference to the actual lens serial number.  I'm guessing that would not work in the EXIF tool GUI interface?

Thanks for helping me solve this mystery.  And for the great support of the tool!!
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 09:46:09 AM
My 7D firmware 3.7.5 and 1.0.8 samples do have an InternalSerialNumber in the MakerNotes, but this (presumably) is for the body.  I was talking about LensSerialNumber in my last post.

You can do the cross-reference with the GUI too.  It is done with the config file.  I can provide an example later when I have more time.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 10:30:45 AM
Phil,

Yep,you're right - it is the Lens Serial Number.  I would very much appreciate an example of how to cross-reference the ASCII to the real serial number when you have time.

Just so you know why I was trying to figure this data string out - a friend gave me his 24-105 to test with mine.  After shooting for a while, and switching lenses, started to look at the images and figure out which ones were shot with his 24-105 or mine.  Noticed the "Lens Serial Number" but it didn't relate to the number on either lens.  Finally just shot one image with one lens and noted the ASCII string.  And been scratching my head ever since.

By the way, not being command-line smart, it took me a long time to figure out how to get a readable html file.  On your home-page, you show an example of an html output using "exiftool -h -canon pics/IMG_0315.jpg"      Would it be helpful to other novices to show that as "exiftool -h -w htm -canon pics/IMG_0315.jpg"  I kept reading about the -w switch but it kept saying "text output" until I finally tried the -w htm

Anyway, just a thought cause I kept trying the way it was shown in your example and got nothing.  Maybe I was just doing it wrong.

Looking forward to you example of a cross-reference, hopefully you will have time to show me in both just the tool and the GUI.  (Any updates from Bogdan?  Hope he is ok.)

Thanks
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 10:40:42 AM
The config file to do what you want would look something like this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyLensSerialNumber => {
            Require => 'LensSerialNumber',
            ValueConv => '$val',
            PrintConv => {
                '0000130aff' => 'The actual serial number',
                '0000154321' => 'The other serial number',
                # etc...
            },
        },
    },
);


see the sample config file (https://exiftool.org/config.html) for instructions on activating a config file.

All text output (HTML is a form of text) from the command-line application goes to the console by default.  As you discovered, the -w option may be used to write this to a file, but the more usual way to do this is using the shell redirection feature, like this:

exiftool -h a.jpg > out.html

This isn't explained in detail in the ExifTool documentation because it is a feature of the shell, not exiftool, but it does appear in some of the examples.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 10:47:34 AM
Phil,

WOW - thanks!  Can you sort of tell me how to enter this in the GUI interface, please?

Redirection & Output - I haven't heard those terms in a very long time - gotta did out my old command line books.

Don't laugh, I still haven't figured out how get the output to pause (page) rather than scroll the whole thing - that's why I had to get to to write somewhere......
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 10:51:38 AM
You don't enter the config file in the GUI.  You create a plain text file containing the code I posted, then save this as ".ExifTool_config" in your home directory (or other location as explained in the sample config file I linked in my last post).

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 11:12:21 AM
Phil,

I may have mis-understood - you had mentioned earlier that "You can do the cross-reference with the GUI too."  I think it was about five posts back.  Thats why I thought there was some way of doing it in the GUI interface so it would convert the ASCII.

Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 11:32:57 AM
Yes.  The config file, properly activated, will apply to the ExifToolGUI as well.  You don't have to do anything in the GUI to get this working.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 11:42:34 AM
Phil,

So if I understand (I hope) - the config file sits in the same directory and the tool (and GUI) - it runs in the background so when I see a Lens Serial Number presented in the Exif data (both from the command line or in running the GUI, it replaces the ASCII with the value I have supplied instead............
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 11:47:44 AM
Close.  The config file should add a new tag called MyLensSerialNumber to the output.  The existing LensSerialNumber tag isn't affected.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 12:32:47 PM
Phil,

Getting close, but -- here is the conf file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyLensSerialNumber => {
            Require => 'LensSerialNumber',
            ValueConv => '$val',
            PrintConv => {
                '0004269a5' => '4545853',
                '0001c0f94' => '3735253',
                # etc...
            },
        },
    },
);


And here is the command line I am using:

C:\exiftool -config test.Exiftool_config -k -g1 -h -w htm  7Dtest4.CR2


It did add the line in the Composite data: 

My Lens Serial Number   Unknown (00001c0f94)


So, what did I miss?  Should this be in the Canon Maker Notes grouping?  And, apparently the -config option has to be first in the command line?


Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 12:39:08 PM
You missed a zero.  It should be 00001c0f94 in the config file, not 0001c0f94.

Yes, the -config option must be first.  But you don't need this option if you put the config file in a standard location.  See FAQ number 11 (https://exiftool.org/faq.html#Q11) for help.

This is a Composite tag, so it goes in the Composite group.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 12:54:01 PM
Phil,

Well, that worked great - finally.

So, I put the ExiftoolGUI.exe in the same directory and ran it - don't see any of the "Composite" information, and definitely not the My Lens Serial Number.  All I did to run the GUI was double click on the exe file.  Do I need to add a switch or shortcut to run with the config file?

Also, any way to get the new line, My Len, in the Canon grouping?  I'm not sure I know what the "Composite" is for.

Sorry to be taking so much of your time today.  I do appreciate your patience.
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 01:04:44 PM
You can put the tag in any group you want by adding something like this to the Composite tag definition:

            Groups => { 0 => 'MakerNotes', 1 => 'Canon' },

About the config file in the GUI.  Maybe you could search the GUI section of the forum to see if Bogdan gave any hints about how to do this.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 01:25:49 PM
Phil,

I had done a search over in the GUI forum but no luck on "Composite" - there is an option for showing Composite in "All" but it still isn't showing the new line, My Lens, so I'm guessing its not running the config file.

Is this what you meant by adding the Group def to the Composite?  Probably not since it doesn't work.

So, two issues - how to get GUI to run/see the config file and move the tag to Maker Notes/Canon group.



%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyLensSerialNumber => {
            Require => 'LensSerialNumber',
            ValueConv => '$val',
            PrintConv => {
                '00004269a5' => '4545853',
                '00001c0f94' => '3735253',
                # etc...
      Groups => { 0 => 'MakerNotes', 1 => 'Canon' },      
            },
        },
    },
);
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 01:31:46 PM
Here's where it should go:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyLensSerialNumber => {
            Require => 'LensSerialNumber',
            Groups => { 0 => 'MakerNotes', 1 => 'Canon' },
            ValueConv => '$val',
            PrintConv => {
                '00004269a5' => '4545853',
                '00001c0f94' => '3735253',
                # etc...
            },
        },
    },
);


- Phil

Edit: Reading the GUI documentation, there is a "Show Composite tags in view ALL" option.
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 01:48:04 PM
Phil,

Getting close, very close.  By putting the Group in the conf file, the tool now puts My Lens Serial Number right below Lens Serial Number, so the ASCII and what is marked on the Lens are adjacent and in the Canon group.

Now, it sure looks like the GUI just doesn't load/run the config file and I'm not sure is adding that -config switch would work.  I'm keeping the GUI exe in the same directory as the tool exe and the .ExifTool_config.

Running the tool works, running the GUI doesn't.

More reading in the GUI forum material..............

Oh, I had edited my previous post since I found the GUI option for including the composite - sorry you had already read the post before I found it.
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 01:53:41 PM
Phil,

Just a thought, do you know if Bogdan runs any "switches" when he executes the tool?

Second, with the Workspace Manger in the GUI, could I add this new field (is it really a new Tag?) to the Workspace?
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 01:54:59 PM
Did you try putting "exiftool.exe" and ".ExifTool_config" both in the c:\windows directory?

Also, the name must be exactly ".ExifTool_config".  How did you rename the file (because I don't think you can do this in Windows without using the command-line "rename" command).

I don't know what switches you mean.  But you should be able to add any tag to the workspace.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 02:06:50 PM
Phil,

I currently have the exiftool.exe, lens.ExifTool.exe, and ExifToolGUI.exe all in the C:\ directory.

And when I run the following command line, the config file works just fine:  C:\exiftool -config lens.Exiftool_config -g1 -w txt 7Dtest4.CR2

You said earlier that I really don't need the -config option, so let me try this without it and see if the tool still produces the correct result.

Oh, I'm calling the -g1, -h, -config, etc. "switches", I guess they are options...........
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 02:13:23 PM
Phil,

I think this has something to do with the config file not loading.  I changed the command line to:  C:\exiftool -g1 -w txt 7Dtest4.CR2 and did not get the new entry.  The file lens.ExifTool_config is in the same location as the exiftool.exe

This have anything to do with the Environment variable you mention in the FAQ #11?
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 02:17:55 PM
I think you weren't paying attention or didn't understand what I was trying to say, so I'll be explicit:

In a cmd.exe window, type these commands:

cd c:\
rename lens.Exiftool_config .ExifTool_config


Then try again.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 02:22:40 PM
Phil,

Yep, I got that.

I'm in Windows 7 and am trying to figure out how to get to a command line window ---- been years.

So, since I was using the -config option, as you say in your documentation, any file name will work, but for it to run without that option, the file has to be renamed starting with the "."

Give me a few minutes..................
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 02:24:32 PM
Yes. The config file name must start with a ".".

I'm confused.  I though you were already running exiftool commands in the command-line window.  You do the "rename" command in the same window.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 02:33:32 PM
Phil,

I've been brain-washed by Windows for so long.

I was running the command in the Windows "Run" line - just filling in the string in the "Run" window.

Man, took me a while to remember "cmd" ----- sorry.

But ----- HORRAY ------- this works so well now.   And, yes, it works in the GUI tool, too.  Plus, I'm so glad you told me how to get it into the Canon group  - I guess I shouldn't ask how to reorder those entries ---

Sorry this has taken so much of your time today.  Thank you so much for your help.

Now, I need to go to all my lenses and add them into the config file.

This is so cool..............Thank you again,

Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 03:20:49 PM
Phil,

Reflecting on what we've done today, it looks to me like the conf file basically looks for a value, the ASCII, finds it and inserts the new value in a new Tag called "My Lens Serial Number" and then puts that in the Canon group.

Just curious, was there a way to find the existing and replace it in the existing Tag "Lens Serial Number" and not create a new Tag?  Or if it can be done, is it not considered good programming to mess with existing tags?

Probably over-thinking this......
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 06:53:00 PM
Yes, you can override the definition of any tag if you want, but I don't suggest this.

The Composite tags are designed to allow you to take modify and combine the values of one or more other tags, so they are able to do what you want.  I don't even really like the idea of changing the group of a Composite tag to look like it came from somewhere else -- this is the first time anyone has ever requested this -- but mine is not to reason why...

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 07:06:09 PM
Phil,

Thanks.  Guess I was just thinking before I realized you could display the Composite in the GUI.

Just out of curiosity, in our example, how would your actually replace the LensSerialNumber with the actual serial number - just for my education in coding a "find and replace" example.

Also, you have no idea how long it took me to add two additional lenses in the config file.  I was using the tab key to get over to where you had put the first two entries.  Then nothing worked.  So, I finally used the space bar to move over and the two additional lines worked as well as the original lines.  Now, all my lenses show the actual serial numbers.  (Except of the little Nifty Fifty plastic guy that shows an all 0000000000 number - guess it doesn't have an internal serial number.

Thanks



Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 06, 2012, 07:25:53 PM
Quote from: roxie380 on December 06, 2012, 07:06:09 PM
Just out of curiosity, in our example, how would your actually replace the LensSerialNumber with the actual serial number - just for my education in coding a "find and replace" example.

The easiest way is to copy the existing definition from the appropriate ExifTool library module and put it into the config file in the proper section, then modify it for your devious means.

QuoteAlso, you have no idea how long it took me to add two additional lenses in the config file.  I was using the tab key to get over to where you had put the first two entries.  Then nothing worked.

Odd.  Tabs are fine in Perl.  This should have worked.  Somehow your text editor was doing something else funny.  Perhaps your editor wasn't using the standard ASCII tab character.  There are a number of invisible UTF-8 characters which definitely would cause problems.  This is a big problem for OS X users because if you cut and paste code examples from here with Safari, you get a bunch of UTF-8 non-breaking-spaces instead of standard ASCII space characters, and these cause syntax errors in the code.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 06, 2012, 07:33:06 PM
Phil,

Devious?  Well, we've gone this far, where do I find the ExifTool library module and where is the correct place in the config file?  Do you have an example somewhere I could look at?

You know, I have no idea about the tab vs space characters - I even edited the file and used the command window to rename it again just in case that was the problem.

What a day - I've learned so much - sorry it took so many messages and replies.

Thanks very much!
Title: Re: Canon Lens Serial Number string
Post by: Phil Harvey on December 07, 2012, 07:16:17 AM
The library modules are included in all ExifTool distributions, but they aren't very easy to find in the Windows or Mac versions.  Look in the "lib/Image/ExifTool" directory in the full distribution, or you can browse them online here (http://search.cpan.org/dist/Image-ExifTool/).  Click on the module, then click on the "Source" link to view the source code.  The definitions are added to the config file in exactly the same way as the ones in the example config file.  And if you want to get into all of the details, the lib/Image/ExifTool/README file documents the meanings of everything in these tables.

- Phil
Title: Re: Canon Lens Serial Number string
Post by: roxie380 on December 07, 2012, 07:51:58 AM
Phil,

Thanks so much for your help.

I don't know if anyone else have found this interesting (lots of views) but I certainly have learned a lot with your help (and patience).

Who knows what Canon may do with other upgrades.

Thank you!