Thread

Posted on Tue Mar 18 00:56:25 2008 by pauljsolomon
Adding other tags as keywords in exiftool
I would like to be able to add the lens (EXIF) setting as a keyword. Also, I believe I would need to remove the spaces (e.g. EF 16-35mm f/2.8 USM").

It would be something like exiftool -keywords+='$Lens', but I believe this inserts the literal "$Lens" as a keyword. Is there anyway to do this? My workaround is to use the "if" and test each lens then hardcode it into my script. Not optimal...

-paul.
Direct Responses: 7376 | Write a response
Posted on Tue Mar 18 03:31:40 2008 by exiftool in response to 7373
Re: Adding other tags as keywords in exiftool
hi paul, you can use user-defined tags to modify the lens string value before writing it to the keywords.
Direct Responses: 7610 | 7611 | Write a response
Posted on Tue Apr 8 04:31:15 2008 by morganglines in response to 7376
Re: Adding other tags as keywords in exiftool
I've had no problems using
exiftool -overwrite_original '-LensType+>keywords' -ext mie .
to do what's described above, but in the case of my 20mm Sigma Exiftool identifies it as either that or a 14mm Canon (I wish!). So, I'm doing something similar with lens type and iso:
exiftool -v -overwrite_original -keywords+="Canon EF 50mm f/1.4 USM" -keywords+="lens:maker=Canon" +-keywords+="lens:focal_min=50" -keywords+="lens:focal_max=50" -if '$MaxAperture eq "1.4"' -if '$Fo +calLength eq "50.0mm"' -v -ext mie . -execute -overwrite_original -keywords+="Sigma 20mm EX f/1.8" + -keywords+="lens:maker=Sigma" -keywords+="lens:focal_min=20" -keywords+="lens:focal_max=20" -if ' +$MaxAperture eq "1.8"' -if '$FocalLength eq "20.0mm"' -q -ext mie . -execute -overwrite_original - +keywords+="Plastic Wonder" -keywords+="Canon EF 50mm f/1.8 MkII" -keywords+="lens:maker=Canon" -ke +ywords+="lens:focal_min=50" -keywords+="lens:focal_max=50" -if '$MaxAperture eq "1.8"' -if '$Focal +Length eq "50.0mm"' -q -ext mie . -execute -overwrite_original -keywords+="Canon EF 100mm f2.8 Mac +ro USM" -keywords+="macro" -keywords+="close up" -keywords+="lens:maker=Canon" -keywords+="lens:fo +cal_min=100" -keywords+="lens:focal_max=100" -if '$MaxAperture eq "2.8"' -if '$FocalLength eq "100 +.0mm"' -q -ext mie . -execute -overwrite_original -keywords+="Canon EF 135mm f/2L" -keywords+="Can +on EF 135mm f/2L+1.4xTC" -keywords+="1.4xTC" -keywords+="lens:maker=Canon" -keywords+="lens:focal_ +min=135" -keywords+="lens:focal_max=135" -if '$MaxAperture eq "2.0"' -if '$FocalLength eq "189.0mm +"' -if '$ShortFocal eq "135mm"' -if '$LongFocal eq "135mm"' -q -ext mie . -execute -overwrite_orig +inal -keywords+="Canon EF 135mm f/2L" -keywords+="lens:maker=Canon" -keywords+="lens:focal_min=135 +" -keywords+="lens:focal_max=135" -if '$MaxAperture eq "2.0"' -if '$FocalLength eq "135.0mm"' -q - +ext mie . -execute -overwrite_original -keywords+="Canon EF 100-400mm f/4.5-5.6L IS" -keywords+="C +anon EF 100-400mm f/4.5-5.6L IS+1.4xTC" -keywords+="1.4xTC" -keywords+="lens:maker=Canon" -keyword +s+="lens:focal_min=140" -keywords+="lens:focal_max=560" -if '$MaxAperture eq "8"' -if '$ShortFocal + eq "140mm"' -if '$LongFocal eq "560mm"' -q -ext mie . -execute -overwrite_original -keywords+="Ca +non EF 100-400mm f/4.5-5.6L IS" -keywords+="lens:maker=Canon" -keywords+="lens:focal_min=100" -key +words+="lens:focal_max=400" -if '$MaxAperture eq "4.5"' -if '$FocalLength eq "135.0mm"' -q -ext mi +e . -execute -overwrite_original -keywords+="Canon EF 35mm f/2" -keywords+="lens:maker=Canon" -key +words+="lens:focal_min=35" -keywords+="lens:focal_max=35" -if '$MaxAperture eq "2.0"' -if '$FocalL +ength eq "35.0mm"' -q -ext mie . -execute -overwrite_original -FNumber="11.0" -FocalLength="16.0mm +" -keywords+="16mm MC Zenitar Fisheye Lens" -keywords+="Fisheye" -keywords+="lens:maker=Zenitar" - +keywords+="lens:focal_min=16" -keywords+="lens:focal_max=16" -if '$FocalLength eq "0.0mm"' -q -ext + mie . -execute -overwrite_original -keywords+="Canon Macro Ring Lite MR-14EX" -if '$MaxAperture e +q "2.8"' -if '$FocalLength eq "100.0mm"' -if '$Flash eq "On"' -if '$CanonFlashMode eq "External fl +ash"' -q -ext mie . -execute -overwrite_original -keywords+="Canon EF 28-135mm f/3.5-5.6 IS" -keyw +ords+="lens:maker=Canon" -keywords+="lens:focal_min=28" -keywords+="lens:focal_max=135" -if '$MaxA +perture eq "3.5"' -if '$ShortFocal eq "28.0mm"' -if '$LongFocal eq "135.0mm"' -v -ext mie .
Exiftool redirects the values into keywords beautifully, but I've not figured out how to include the name of the tag along with the value. I also see a lot of validity to the argument that tags already present in the images shouldn't necessarily be written out as keywords. (I backup my metadata first to mie files, geotag to xmp, copy the xmp into the mie files to get the geodata, then modify the mie files with lens tags and other details before restoring back to processed JPEGs) Anyone know if there's repository of scripts featuring exiftool? It's so amazingly flexible I'd imagine people must have come up with some neat ones.
Write a response
Posted on Tue Apr 8 04:34:13 2008 by morganglines in response to 7376
Re: Adding other tags as keywords in exiftool
I've had no problems using
exiftool -overwrite_original '-LensType+>keywords' -ext mie .
to do what's described above, but in the case of my 20mm Sigma Exiftool identifies it as either that or a 14mm Canon (I wish!). So, I'm doing something similar with lens type and iso:
exiftool -v -overwrite_original -keywords+="Canon EF 50mm f/1.4 USM" -keywords+="lens:maker=Canon" +-keywords+="lens:focal_min=50" -keywords+="lens:focal_max=50" -if '$MaxAperture eq "1.4"' -if '$Fo +calLength eq "50.0mm"' -v -ext mie . -execute -overwrite_original -keywords+="Sigma 20mm EX f/1.8" + -keywords+="lens:maker=Sigma" -keywords+="lens:focal_min=20" -keywords+="lens:focal_max=20" -if ' +$MaxAperture eq "1.8"' -if '$FocalLength eq "20.0mm"' -q -ext mie . -execute -overwrite_original - +keywords+="Plastic Wonder" -keywords+="Canon EF 50mm f/1.8 MkII" -keywords+="lens:maker=Canon" -ke +ywords+="lens:focal_min=50" -keywords+="lens:focal_max=50" -if '$MaxAperture eq "1.8"' -if '$Focal +Length eq "50.0mm"' -q -ext mie . -execute -overwrite_original -keywords+="Canon EF 100mm f2.8 Mac +ro USM" -keywords+="macro" -keywords+="close up" -keywords+="lens:maker=Canon" -keywords+="lens:fo +cal_min=100" -keywords+="lens:focal_max=100" -if '$MaxAperture eq "2.8"' -if '$FocalLength eq "100 +.0mm"' -q -ext mie . -execute -overwrite_original -keywords+="Canon EF 135mm f/2L" -keywords+="Can +on EF 135mm f/2L+1.4xTC" -keywords+="1.4xTC" -keywords+="lens:maker=Canon" -keywords+="lens:focal_ +min=135" -keywords+="lens:focal_max=135" -if '$MaxAperture eq "2.0"' -if '$FocalLength eq "189.0mm +"' -if '$ShortFocal eq "135mm"' -if '$LongFocal eq "135mm"' -q -ext mie . -execute -overwrite_orig +inal -keywords+="Canon EF 135mm f/2L" -keywords+="lens:maker=Canon" -keywords+="lens:focal_min=135 +" -keywords+="lens:focal_max=135" -if '$MaxAperture eq "2.0"' -if '$FocalLength eq "135.0mm"' -q - +ext mie . -execute -overwrite_original -keywords+="Canon EF 100-400mm f/4.5-5.6L IS" -keywords+="C +anon EF 100-400mm f/4.5-5.6L IS+1.4xTC" -keywords+="1.4xTC" -keywords+="lens:maker=Canon" -keyword +s+="lens:focal_min=140" -keywords+="lens:focal_max=560" -if '$MaxAperture eq "8"' -if '$ShortFocal + eq "140mm"' -if '$LongFocal eq "560mm"' -q -ext mie . -execute -overwrite_original -keywords+="Ca +non EF 100-400mm f/4.5-5.6L IS" -keywords+="lens:maker=Canon" -keywords+="lens:focal_min=100" -key +words+="lens:focal_max=400" -if '$MaxAperture eq "4.5"' -if '$FocalLength eq "135.0mm"' -q -ext mi +e . -execute -overwrite_original -keywords+="Canon EF 35mm f/2" -keywords+="lens:maker=Canon" -key +words+="lens:focal_min=35" -keywords+="lens:focal_max=35" -if '$MaxAperture eq "2.0"' -if '$FocalL +ength eq "35.0mm"' -q -ext mie . -execute -overwrite_original -FNumber="11.0" -FocalLength="16.0mm +" -keywords+="16mm MC Zenitar Fisheye Lens" -keywords+="Fisheye" -keywords+="lens:maker=Zenitar" - +keywords+="lens:focal_min=16" -keywords+="lens:focal_max=16" -if '$FocalLength eq "0.0mm"' -q -ext + mie . -execute -overwrite_original -keywords+="Canon Macro Ring Lite MR-14EX" -if '$MaxAperture e +q "2.8"' -if '$FocalLength eq "100.0mm"' -if '$Flash eq "On"' -if '$CanonFlashMode eq "External fl +ash"' -q -ext mie . -execute -overwrite_original -keywords+="Canon EF 28-135mm f/3.5-5.6 IS" -keyw +ords+="lens:maker=Canon" -keywords+="lens:focal_min=28" -keywords+="lens:focal_max=135" -if '$MaxA +perture eq "3.5"' -if '$ShortFocal eq "28.0mm"' -if '$LongFocal eq "135.0mm"' -v -ext mie .
Exiftool redirects the values into keywords beautifully, but I've not figured out how to include the name of the tag along with the value. I also see a lot of validity to the argument that tags already present in the images shouldn't necessarily be written out as keywords. (I backup my metadata first to mie files, geotag to xmp, copy the xmp into the mie files to get the geodata, then modify the mie files with lens tags and other details before restoring back to processed JPEGs) Anyone know if there's repository of scripts featuring exiftool? It's so amazingly flexible I'd imagine people must have come up with some neat ones.
Direct Responses: 7617 | Write a response
Posted on Tue Apr 8 14:22:21 2008 by exiftool in response to 7611
Re: Adding other tags as keywords in exiftool
As you have noticed the 3rd party lenses such as those by Sigma often use the same LensType number as an OEM lens. This makes identification more difficult and you have to get into guessing the lens model from other meta information as you are doing by checking the focal length.

To include the name of the tag along with the value, you would do something like this:

exiftool '-keywords+<lens=$lens' FILE

This will add a keyword like "lens=75.0 - 300.0 mm" to FILE. Note that the single quotes are used in most Unix shells (as apparently you are using), while double quotes would be necessary in Windows.

Other than what people have posted in this forum, I don't keep a library of scripts that people have written. However, if someone publishes a script or utility that uses exiftool (and tells me about it), I put a link in the "Related Utilities" section of the exiftool home page.

- Phil
Write a response