Problem adding LensType to Keywords

Started by PercyVera, January 03, 2015, 02:27:46 PM

Previous topic - Next topic

PercyVera

I am having trouble adding the lens type and camera model to the list of keywords.

Attempt 1:
exiftool '-Keywords+<Model' '-Keywords+<LensType' file.jpg
Unfortunately, this copies only LensType, as I later found explained in section 17 of the FAQ.

Attempt 2:
exiftool -addTagsFromFile @ '-Keywords+<Model' '-Keywords+<LensType' file.jpg
Although this copies Model, it results in LensType appearing twice in the resulting keywords.
After some head-scratching and use of the -a option, I found that the LensType tag occurs twice in the original jpg: once with tag id 22 (MakerNotes:Canon:Camera:Main} and again with tag id 255 (MakerNotes:Canon:Camera:Main:Copy1). I guess this is where the unwanted keyword is coming from.

Attempt 3:
exiftool '-Keywords+<Model' file.jpg -execute '-Keywords+<LensType' file.jpg
This achieves the desired result (one occurrence each of the two tag values), and is faster than two separate commands.

Since then, I have noticed that the value of LensType is also in ExifTool's output under the LensID tag (Composite:Composite:Camera:Main). Using LensID instead of LensType in Attempt 2 gives the required value of Keywords, so this may be my solution.

But if LensID did not exist I would have to use Attempt 3, which seems 'wrong'.
Is there a correct/preferred way of suppressing the duplicate LensType while still allowing both LensType and Model to be copied by the same command?

Paul

Phil Harvey

Hi Paul,

Interesting.  If both LensType tags are in different family 0 or 1 groups, then you could specify a group name to copy only one.  The real problem here is that the duplicates option always applies when copying tags, and that the normal way to get only one copy of a tag is to disable this option.  You can specify copy1:LensType to get the 1st copy only, but unfortunately the 0th copy doesn't have a family 4 group name, and currently specifying 4:LensType doesn't work, so using the copy number doesn't get you out of this situation.  I will patch ExifTool 9.79 so that 4:LensType works, and that will give you a more elegant (albeit esoteric) solution.

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

PercyVera

Thanks, Phil.

I thought that in the meantime I would try to implement a solution by creating a composite tag (myLensType) whose value is simply copied from Copy1:LensType.

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::Composite' => {
    myLensType => {
      Require => 'Copy1:LensType',
      ValueConv => '$prt[0]',
    },
  },
);


This indeed creates a myLensType tag with the correct value (Composite:Composite:Other:Main), but it also creates a copy of the new tag (Composite:Composite:Other:Main:Copy1). So when I substitute myLensType in Attempt 2 of my initial post, I still get a duplicate Keyword. Gah!

Oh, well.

Paul

Phil Harvey

Hi Paul,

If using Copy1:LensType was good for you, you don't need a Composite tag.  Just do this:

exiftool '-Keywords+<Model' '-Keywords+<Copy1:LensType' file.jpg

My concern was this wouldn't work if there was only one LensType tag.  But with ExifTool 9.79 (just released), will allow this:

exiftool '-Keywords+<Model' '-Keywords+<4:LensType' file.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 ($).