Add IPTC:Keywords from tiff to jpg

Started by mmjoshi, March 07, 2024, 05:06:24 AM

Previous topic - Next topic

mmjoshi

I have a directory "tiff" which contains only tif files and another directory "jpg" which contains only jpg files. For every file in the tiff directory, there is a matching jpg file in the jpg directory with the same file name except the extension is jpg.

Each file in the two directories have IPTC:Keywords information. The value of the IPTC:Keywords tag is different in the two directories. How do I add the IPTC:Keywords information in the tif files to the information in the jpg files. I want to ADD and not REPLACE.

I would like to do this in a batch file. I am fairly conversant with the command line options of exiftool though I can not say I am an expert!

Phil Harvey

This should do it:

exiftool -tagsfromfile TIFF_DIR/%f.tiff "-iptc:keywords+<iptc:keywords" -ext jpg JPG_DIR

The +< copies the tag, adding it to existing entries for List-type tags such as IPTC:Keywords.

If you put this in a Windows .bat file, then change the % to %%.

- 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

#2
Hi Phil

Thanks for the quick response. I am trying this in a Windows 11 batch file. I changed that % to %%. However, both my tif and jpg directories as well as all the file names are having spaces in them.


e.g My tiff directory -> K:\Edited Photographs - tif and the jpg directory -> K:\Edited Photographs - jpg

the tiff file names -> A7 II - 0,00,307.tif and the jpg file name -> A7 II - 0,00,307.jpg

I am having the following command in my Windows batch file.

D:\PortablePrograms\ExifTool\exiftool.exe -tagsfromfile "K:\Edited Photographs - tif"\%%f.tiff "-iptc:keywords+<iptc:keywords" -ext jpg "K:\Edited Photographs - jpg"

I guess I need to enclose the directory as well as the file name in double quotes. However, even after trying few combinations I am getting the  following error and no files are changed.

Warning: Error opening file - K:\Edited Photographs - tif\A7 II - 0,00,307.tiff
How should I format my command to take care of the spaces?

StarGeek

Your command should work, as I don't see any problems with it.  Personally, I would enclose the quotes like this, but that's just a matter of style
D:\PortablePrograms\ExifTool\exiftool.exe -tagsfromfile "K:\Edited Photographs - tif\%%f.tiff" "-iptc:keywords+<iptc:keywords" -ext jpg "K:\Edited Photographs - jpg"

First check to make sure that
K:\Edited Photographs - tif\A7 II - 0,00,307.tiff is the exact path and filename for the tiff file.

Don't copy/paste commands into a word processor/Google Docs, as they will "help" you by "fixing" the quotes from standard straight quotes to fancy/curly

Another possible issue is that you might have non-breaking space instead of a normal space in the command. This can sometimes happen when copy/pasting from webpages.

Example of command working correctly on my system
C:\>type temp.bat
exiftool -P -overwrite_original -tagsfromfile "Y:\!temp\x\Edited Photographs - tif\%%f.tiff" "-iptc:keywords+<iptc:keywords" -ext jpg "Y:\!temp\x\Edited Photographs - jpg"

C:\>exiftool -G1 -a -s -Keywords -r Y:\!temp\x
======== Y:/!temp/x/Edited Photographs - jpg/20140257_6918.jpg
[IPTC]          Keywords                        : Keyword One, Keywords Two
======== Y:/!temp/x/Edited Photographs - tif/20140257_6918.tiff
[IPTC]          Keywords                        : Keyword Three, Keywords Four
    3 directories scanned
    2 image files read

C:\>temp.bat

C:\>exiftool -P -overwrite_original -tagsfromfile "Y:\!temp\x\Edited Photographs - tif\%f.tiff" "-iptc:keywords+<iptc:keywords" -ext jpg "Y:\!temp\x\Edited Photographs - jpg"
    1 directories scanned
    1 image files updated

C:\>exiftool -G1 -a -s -Keywords -r Y:\!temp\x
======== Y:/!temp/x/Edited Photographs - jpg/20140257_6918.jpg
[IPTC]          Keywords                        : Keyword One, Keywords Two, Keyword Three, Keywords Four
======== Y:/!temp/x/Edited Photographs - tif/20140257_6918.tiff
[IPTC]          Keywords                        : Keyword Three, Keywords Four
    3 directories scanned
    2 image files read
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mmjoshi

Hi StarGeek

Thanks for your inputs. I feel so silly and feel like banging my head about my own stupidity. I should have realized that Phil's command line mentions the extension as tiff where as my files have the extension tif. Obviously the command would not find the files!

I corrected the error and the command works perfectly. However, I do get the following error:

Warning: IPTCDigest is not current. XMP may be out of sync - K:\Edited Photographs - tif\A7 II - 0,00,307.tif

Is this something I need to worry about? Or just ignore it?


StarGeek

Quote from: mmjoshi on March 07, 2024, 11:24:27 PMI should have realized that Phil's command line mentions the extension as tiff where as my files have the extension tif. Obviously the command would not find the files!

Homer Simpson D'oh moments are the norm for me.  I make far too many of them.

QuoteI corrected the error and the command works perfectly. However, I do get the following error:

Warning: IPTCDigest is not current. XMP may be out of sync - K:\Edited Photographs - tif\A7 II - 0,00,307.tif

You can see my commentary on the IPTCDigest tag in this post.

In your case, if you're only using IPTC IIM/Legacy tags and not using XMP (IPTC Core/Ext) tags, then you can bulk delete the IPTCDigest tag with -IPTCDigest=  If you are keeping IPTC and XMP tags in sync, then you can update it as listed in the link.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mmjoshi

Hmm. Good to know that I am not alone. :)

I use darktable, FSView, IrfanView, Gimp and digiKam for all my photo management requirements. All opensource! So far I have not seen the need for using xmp tags. All the tag information seems to be stored in IPTC by digiKam.

My typical workflow is as follows:

01. Add the RAW files to the digiKam collections.
02. Tag these files with the date and any other information I need to find the images later on.
03. Process these images in darktable.
04. Export the processed images to Gimp for further processing.
05. After processing, export the processed images as tiff from Gimp.
06. Convert the tiff files to jpg using FSView and later IrfanView to reduce the size.
07. Add the processed files to digiKam collections, tif and jpg mentioned earlier in my first post.

All these programs use IPTC for tagging.

Hence, I will just delete the IPTCDigest from the tif files as suggested by you.

On a more aggressive side, will it be harmful if I just delete all the xmp tags from the tif files. Will that be causing problems later on? What's your take on this?

StarGeek


Irfanview isn't open source AFAIK.  But it's still a good program.

DigiKam is most likely writing to XMP as well as IPTC, though it is probably listing it as IPTC. What they mean by that is that they would be using IPTC Photo Metadata Standard.  The IPTC Core and Extension tags are in XMP.

Personally, I suggest XMP, as it's far more flexible.  Additionally, the older IPTC IIM standard has limits on how much data can be in a tag. For example, the Sub-location tag is supposed to be limited to 32 characters, which would be a problem if you took a picture on this hill.  By default, exiftool will enforce this and truncate longer text, but this can be overridden with the -m (-ignoreMinorErrors) option.  The limit is ignored by most other modern programs, such as DigiKam, so it would only be a problem if you're editing an IPTC tag with exiftool.

Since the latest version of Irfanview finally has the ability to display XMP data, I'm going to be ditching IPTC altogether, as it was the only program that I used that wouldn't display XMP data and I use it to quickly look at metadata without having to use exiftool or open a image management program.

Irfanview's XMP display
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mmjoshi

Quote from: StarGeek on March 08, 2024, 12:10:27 PM
Irfanview isn't open source AFAIK.  But it's still a good program.

Thanks for your patience and excellent inputs. I keep learning. Oh, I didn't know that IrfanView is not opensource. I use the portable version from PortableApps.com where I think the policy is to list only opensource programs. I could be wrong though. I agree it's a very good program.

QuoteDigiKam is most likely writing to XMP as well as IPTC, though it is probably listing it as IPTC. What they mean by that is that they would be using IPTC Photo Metadata Standard.  The IPTC Core and Extension tags are in XMP.

My xmp tags are all screwed up! Most of my processed tiff files are missing them. However all of them do have the IPTC tags. I was thinking of deleting the xmp tags from those files which have them to keep consistency. Any harm in doing that?

QuotePersonally, I suggest XMP, as it's far more flexible.  Additionally, the older IPTC IIM standard has limits on how much data can be in a tag. For example, the Sub-location tag is supposed to be limited to 32 characters, which would be a problem if you took a picture on this hill.  By default, exiftool will enforce this and truncate longer text, but this can be overridden with the -m (-ignoreMinorErrors) option.  The limit is ignored by most other modern programs, such as DigiKam, so it would only be a problem if you're editing an IPTC tag with exiftool.


My tagging is very simple. I just have a tag with the date and some descripiton of where it was taken. e.g.

2017.09.15 to 2017.09.30 - Europe trip

Each tag may have a subtag with further description:

2017.09.26 - Vatican City & Rome

Rarely I may have a further sub tag with at the most 24 characters. I never use the sub-location tag, Didn't even know that such a tag existed! All my tagging is done exclusively in digiKam.

BTW, I can't even type let alone pronounce the name of the hill that you mentioned!

QuoteSince the latest version of Irfanview finally has the ability to display XMP data, I'm going to be ditching IPTC altogether, as it was the only program that I used that wouldn't display XMP data and I use it to quickly look at metadata without having to use exiftool or open a image management program.

Irfanview's XMP display


Which version of IrfanView is this? The one I updated from PortableApps still doesn't display the xmp data.

StarGeek

Quote from: mmjoshi on March 09, 2024, 01:29:32 AMI was thinking of deleting the xmp tags from those files which have them to keep consistency. Any harm in doing that?

No, there's no harm. You only have to worry about editing with exiftool and data that is too long.  You just have to remember to override it with the -m option.

QuoteRarely I may have a further sub tag with at the most 24 characters. I never use the sub-location tag, Didn't even know that such a tag existed! All my tagging is done exclusively in digiKam.

I first really noticed it when I was using GeoSetter way back, and I was using the results it provided, which would be really obscure names for the neighborhoods. Sort of like how NYC has its Boroughs, but for everywhere.  For example, pictures I took at the Anaheim Convention Center would have a location of "Micaflores".

After reading the IPTC definition, I changed it to more recognized names of the locations.  For example, when taking pictures in San Diego as I often do, I would set the location to "San Diego Convention Center", "San Diego Zoo", "Gaslamp Quarter", "Seaport Village", "Balboa Park", and similar things.  Even more mundane names such as the names of parks or the building/store I was in.  It's a little extra work, but I like the results.

QuoteBTW, I can't even type let alone pronounce the name of the hill that you mentioned!

Neither can I, but that's just an extreme example.


QuoteWhich version of IrfanView is this? The one I updated from PortableApps still doesn't display the xmp data.

The newest version, ver. 4.66, Release date: 2023-12-20.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mmjoshi

Quote from: StarGeek on March 09, 2024, 01:59:52 PM
Quote from: mmjoshi on March 09, 2024, 01:29:32 AMI was thinking of deleting the xmp tags from those files which have them to keep consistency. Any harm in doing that?

No, there's no harm. You only have to worry about editing with exiftool and data that is too long.  You just have to remember to override it with the -m option.

Thanks. Will stick to IPTC. Any way my original Pentax and Sony RAW files do contain the xmp information. Just in case! Will also keep your tip in mind in case I need to use ExifTool for tagging.

QuoteRarely I may have a further sub tag with at the most 24 characters. I never use the sub-location tag, Didn't even know that such a tag existed! All my tagging is done exclusively in digiKam.
QuoteI first really noticed it when I was using GeoSetter way back, and I was using the results it provided, which would be really obscure names for the neighborhoods. Sort of like how NYC has its Boroughs, but for everywhere.  For example, pictures I took at the Anaheim Convention Center would have a location of "Micaflores".

After reading the IPTC definition, I changed it to more recognized names of the locations.  For example, when taking pictures in San Diego as I often do, I would set the location to "San Diego Convention Center", "San Diego Zoo", "Gaslamp Quarter", "Seaport Village", "Balboa Park", and similar things.  Even more mundane names such as the names of parks or the building/store I was in.  It's a little extra work, but I like the results.


My tagging is much simpler. I just name the directory with the date and the location. All files in that directory get the same tag! Also, any other tags like architecture, landscape etc.

QuoteBTW, I can't even type let alone pronounce the name of the hill that you mentioned!

QuoteNeither can I, but that's just an extreme example.


Seriously though how do the locals even refer to it during conversation?!


QuoteWhich version of IrfanView is this? The one I updated from PortableApps still doesn't display the xmp data.

The newest version, ver. 4.66, Release date: 2023-12-20.
[/quote]

Interesting. I use the same version. The xmp information is not shown. ExifTool does show the xmp information though. Is there any setting to turn this feature on?
XMP - IrfanView.jpg

StarGeek

Quote from: mmjoshi on March 10, 2024, 12:58:24 AMInteresting. I use the same version. The xmp information is not shown. ExifTool does show the xmp information though. Is there any setting to turn this feature on?

It might only be certain file types. It definitely works on JPEGs.  Doesn't work on PNGs or TIFFs.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mmjoshi

Quote from: StarGeek on March 10, 2024, 10:59:04 AM
Quote from: mmjoshi on March 10, 2024, 12:58:24 AMInteresting. I use the same version. The xmp information is not shown. ExifTool does show the xmp information though. Is there any setting to turn this feature on?

It might only be certain file types. It definitely works on JPEGs.  Doesn't work on PNGs or TIFFs.

That could be it. Thanks.