I've found a few images with multiple IPTC chunks in them. In most cases, the data is the same in each so it's not a problem to fix. But I was wondering if there was an easy way I could delete one or the other IPTC in the few cases there was a difference? Or even an easy way to condense the two sets of data?
This is difficult to answer without knowing where the IPTC is located, but something like this may do what you want:
exiftool -iptc:all= -tagsfromfile @ -iptc:all FILE
Send a sample to me (philharvey66 at gmail.com) if you want a more informed answer.
- Phil
Yeah, that was the command I was using to fix it when the data was the same. I didn't try it on one of the ones that had different data until now.
Very strange, it consolidated all the data into the second IPTC, but didn't remove the first. I poked around and it looked like the first IPTC was in the EXIF. I ran exiftool -exif:all= -tagsfromfile @ -exif:all and that cleared out the first IPTC.
Actually, now that I double check some of the others, I needed to run exiftool -photoshop:all= -tagsfromfile @ -iptc:all to fix some because there were 2 IPTCs in the same photoshop chunk.
Anyway, I'm good now that I can fix them one way or the other. Do you still want to see copies of these weird ones?
It sounds like the IPTC was in the EXIF in one case, which I have seen before. Two IPTC's in the Photoshop information is new to me. You may also find IPTC in Fotostation and AFCP trailers.
To be honest, I'm not sure which of these ExifTool will remove and which it won't. I would have expected it to remove the EXIF IPTC though, so a sample would be useful so I can look into this. (Please email it to philharvey66 at gmail.com, thanks.)
- Phil
Quote from: email exchange with StarGeek
Here's three weird jpgs with multiple IPTCs that I was talking about. One seemed to have two IPTCs in the same photoshop chunk. At least, that's what JpegSnoop indicated. The second did seem to have the IPTC in the Exif chunk and after playing with it some more, ExifTool responded with "Warning: [minor] Not recreating IPTC in IFD0 (should be in Photoshop)". The third one I only just found and has four IPTCs in it so I thought I'd send it along for kicks.
Thanks, this is useful. I can now see exactly what was going on. The command I gave doesn't do what I had hoped for 2 reasons:
1) The IPTC in the EXIF is not removed because ExifTool only edits the JPEG EXIF segment if necessary, so it won't edit this segment if only writing IPTC tags.
2) The duplicate IPTC in the Photoshop information is not removed when adding back IPTC in the same step because I haven't put any logic into ExifTool to prevent writing to multiple IPTC segments like this. (As you have seen by the message "Not recreating IPTC in IFD0", this logic exists for IPTC in the EXIF of JPEG images -- I just need something like this for duplicate IPTC in the Photoshop segment).
The work-around for problem 1 is simple: rewrite any mandatory EXIF tag to force the EXIF to be edited if it exists:
exiftool -iptc:all= -tagsfromfile @ -iptc:all -exifverson FILE(Apparently you stumbled into this solution in the command where you got the "Not recreating IPTC in IFD0" message.)
The solution to problem 2 will appear in ExifTool 8.71 when it is released. I need to add the logic to check for multiple IPTC records in the Photoshop information.
So thanks for sending the samples. It was worthwhile since it revealed an improvement I can make to ExifTool!
- Phil
Edit: Changed to a mandatory EXIF tag to ensure that the tag exists, otherwise EXIF won't be written
There you go. ExifTool 8.71 has been released. Now the command given in my last post should solve all of your multiple IPTC problems.
- Phil