Edit LensType in Makernotes

Started by mmjoshi, October 12, 2016, 08:06:15 AM

Previous topic - Next topic

mmjoshi

I have downloaded the program today and am using it to copy the lens information from Makernotes to the lens model filed in the EXIF. It works perfectly. A minor problem I am facing is with the lens name. I use smc-FA 28-200mm F3.8-5.6 AL[IF] lens. But when the import is done the lens name is converted to  Pentax smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron AF LD 28-200mm F3.8-5.6 [IF] Aspherical (171D). I would like to cut the Tamron part out. Is there any way I can change the lens type to just include the Pentax name? I would like to make this change permanent so that every time I use the Pentax lens the lens model is correct.

Phil Harvey

I assume you are setting LensModel from the value of LensType?  If so, try this:

exiftool "-lensmodel<${lenstype;s/^Pentax //;s/^Tamron //}" DIR

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

mmjoshi

Hi Phil

Thanks for the quick response. I tried it. The files do get modified as I see a backup with the extension .original for all the DNG files in the directory. There is no change in the original and the modified file sizes. Here's what I did:

01. Copied the exiftool to the directory.
02. Opened a command prompt in the directory.
03. Used the command exiftool "-lensmodel<${lenstype;s/^Pentax //;s/^Tamron //}" .
04. I get the prompt
   1 directories scanned
   31 image files updated, but nothing happens.
05. Please note that I had already changed the lens model using the exiftool. Shouldn't the command overwrite the lens model in all the files?

Do let me know if I am doing anything wrong.

mj


Phil Harvey

You can add the -v2 option to see more details about what ExifTool is writing.

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

mmjoshi

Did that. Following is the output of the command for the first few files:

======== ./K20D - 0,05,477.DNG
Setting new values from ./K20D - 0,05,477.DNG
Warning: [minor] Tag 'lenstype' not defined - ./K20D - 0,05,477.DNG
Warning: No writable tags set from ./K20D - 0,05,477.DNG
Nothing changed in ./K20D - 0,05,477.DNG
======== ./K20D - 0,05,478.DNG
Setting new values from ./K20D - 0,05,478.DNG
Warning: [minor] Tag 'lenstype' not defined - ./K20D - 0,05,478.DNG
Warning: No writable tags set from ./K20D - 0,05,478.DNG
Nothing changed in ./K20D - 0,05,478.DNG
======== ./K20D - 0,05,479.DNG
Setting new values from ./K20D - 0,05,479.DNG
Writing MIE-Lens:LensModel
Writing PhaseOne:LensModel if tag exists
Writing Nikon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,479.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron Lens'
    + ExifIFD:LensModel = 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron Lens'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks

I think the tag is removed and the same is written back. What should I try next?

Phil Harvey

Ah, sorry.  I misunderstood what you wanted.

Try this:

exiftool "-lensmodel<${lenstype;s/ or .*//}" DIR

This should remove everything from " or " onwards.

But maybe this is better:

exiftool "-lensmodel<lensid" DIR

since it should better identify the specific lens.

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

mmjoshi

Thanks!

The first command works as shown by the following output:

======== ./K20D - 0,05,477.DNG
Setting new values from ./K20D - 0,05,477.DNG
Writing MIE-Lens:LensModel
Writing Canon:LensModel if tag exists
Writing PhaseOne:LensModel if tag exists
Writing Nikon:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,477.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron AF LD 2[snip]'
    + ExifIFD:LensModel = 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF]'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks
======== ./K20D - 0,05,489.DNG
Setting new values from ./K20D - 0,05,489.DNG
Writing MIE-Lens:LensModel
Writing Canon:LensModel if tag exists
Writing PhaseOne:LensModel if tag exists
Writing Nikon:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Pentax:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,489.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-F 35-105mm F4-5.6'
    + ExifIFD:LensModel = 'smc PENTAX-F 35-105mm F4-5.6'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks
======== ./K20D - 0,05,503.DNG
Setting new values from ./K20D - 0,05,503.DNG
Writing MIE-Lens:LensModel
Writing Canon:LensModel if tag exists
Writing PhaseOne:LensModel if tag exists
Writing Nikon:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Pentax:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,503.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-F 50mm F1.7'
    + ExifIFD:LensModel = 'smc PENTAX-F 50mm F1.7'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks
    1 directories scanned
    3 image files updated

However the second command exiftool "-lensmodel<lensid" DIR does not work as shown by the output. Though, the first command is good enough for my purpose, curious to know why the second command does not work.

Warning: String too long for Canon:LensModel - ./K20D - 0,05,477.DNG
======== ./K20D - 0,05,477.DNG
Setting new values from ./K20D - 0,05,477.DNG
Writing MIE-Lens:LensModel
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing PhaseOne:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,477.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF]'
    + ExifIFD:LensModel = 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron AF LD 2[snip]'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks
======== ./K20D - 0,05,489.DNG
Setting new values from ./K20D - 0,05,489.DNG
Writing MIE-Lens:LensModel
Writing Pentax:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing PhaseOne:LensModel if tag exists
Writing Nikon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,489.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-F 35-105mm F4-5.6'
    + ExifIFD:LensModel = 'smc PENTAX-F 35-105mm F4-5.6'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks
======== ./K20D - 0,05,503.DNG
Setting new values from ./K20D - 0,05,503.DNG
Writing MIE-Lens:LensModel
Writing Pentax:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Olympus:LensModel if tag exists
Writing PhaseOne:LensModel if tag exists
Writing Nikon:LensModel if tag exists
Writing Canon:LensModel if tag exists
Writing Leica:LensModel if tag exists
Writing XMP-exifEX:LensModel if tag exists
Writing XMP-microsoft:LensModel if tag exists
Writing ExifIFD:LensModel
Rewriting ./K20D - 0,05,503.DNG...
  Editing tags in: ExifIFD IFD0 MIE-Lens MakerNotes TIFF XMP
  Creating tags in: ExifIFD IFD0 MIE-Lens TIFF
  FileType = DNG
  FileTypeExtension = DNG
  MIMEType = image/x-adobe-dng
  ExifByteOrder = MM
  Rewriting IFD0
  Rewriting SubIFD
  Rewriting SubIFD1
  Rewriting XMP
  Rewriting ExifIFD
    - ExifIFD:LensModel = 'smc PENTAX-F 50mm F1.7'
    + ExifIFD:LensModel = 'smc PENTAX-F 50mm F1.7'
  Rewriting MakerNotePentax
  Rewriting LensRec
  Rewriting ShakeReductionInfo
  Rewriting AWBInfo
  Rewriting CameraSettings
  Rewriting AEInfo
  Rewriting LensInfo
  Rewriting FlashInfo
  Rewriting CameraInfo
  Rewriting BatteryInfo
  Rewriting AFInfo
  Rewriting KelvinWB
  Rewriting ColorInfo
  Rewriting EVStepInfo
  Rewriting ShotInfo
  Rewriting UnknownInfo
  Copying 3 image data blocks
    1 directories scanned
    3 image files updated

Phil Harvey

The LensID tag is designed to be ExifTool's best guess at the specific lens model used, but under some circumstances it is not possible to uniquely identify the lens, and in these cases the LensID may still contain " or <some other lens>".  It appears that this is the case here, so manually removing the " or ..." to give the OEM lens name seems to be what you need.

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

mmjoshi

Guess I will stick to what works! Thanks! Incidentally I checked with Exiftool Gui and could not find any lens id field. However, PhotoME shows a pair of numbers 3 + 52  for the field lens id. Whatever that means.

Thanks for your tips. At least now I have a working method to add the lens info from the MakerNotes to lens info in EXIF.