Remove metadata EXCEPT certains properites

Started by carlseibert, July 04, 2017, 02:22:59 PM

Previous topic - Next topic

carlseibert

Is there a way to remove all values in a group except for specified properties?

Say, could I with one command remove all Exif data except GPS?  Or all XMP, except IPTC? Or even do both in one go?

StarGeek

Remove the group, then add the tags you want back in with -tagsfromfile @.

Example:
exiftool -EXIF:all= -tagsfromfile @ -GPS:all FileOrDir

Quote from: carlseibert on July 04, 2017, 02:22:59 PM
Or all XMP, except IPTC? Or even do both in one go?

I'm assuming you mean IPTC-Core, because the the group that exiftool calls IPTC (IIM or legacy) is completely separate from XMP and removing one doesn't affect the other.  Removing all XMP except IPTC-Core would be more difficult as I believe those tags are scattered across a couple different XMP groups (XMP-iptcExt, XMP-iptcCore, XMP-dc, and possibly others).  So you would have to research which tags you actually want to save.  But otherwise, the idea is the same. 
exiftool -xmp:all= -tagsfromfile @ -XMP-iptcExt:all -XMP-iptcCore:all -XMP-dc:all FileOrDir
* 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).

carlseibert

Wow. That's cool. I looked at the man page and I think I understand what you're doing. I'll experiment a little to try it out.

If it turns out I'm not understanding correctly, I'll be back.

Thanks!

carlseibert

It turns out that a fistful of useful IPTC tags are mixed into the XMP-photoshop group. But also in that group are some Photoshop logging tags that are problematic. (see this post for an explanation: http://www.carlseibert.com/macron-portrait-metadata/  )

So after some quality reading time with the man page and the XMP reference from this site, I came up with:

exiftool -xmp:all= -tagsfromfile @ -XMP-iptcExt:all -XMP-iptcCore:all -XMP-dc:all -XMP-photoshop:all -XMP-photoshop:History= -XMP-photoshop:DocumentAncestors= -EXIF:all= -tagsfromfile @ -GPS:all -Photoshop:PhotoshopThumbnail= FileOrDir

That saves all the IPTC metadata that I can find, zaps the two potentially troublesome logging tags, and includes stripping the Exif except GPS, and throws in removing the Photoshop Thumbnail for good measure.

I THINK I have found all the obnoxious pieces and removed them, while saving all the important IPTC stuff here. There is a colorspace tag in the Photoshop group and three tags about text layers that I have ignored. I can't see the colorspace information being troll-bait, and JPEGs don't support layers, so I don't see the text layer tags being a problem. But if anybody disagrees, please speak up.

Here's the command with only the XMP bits, without the extra flourishes: exiftool -xmp:all= -tagsfromfile @ -XMP-iptcExt:all -XMP-iptcCore:all -XMP-dc:all -XMP-photoshop:all -XMP-photoshop:History= -XMP-photoshop:DocumentAncestors= FileOrDir

Thanks for your help!


A disclaimer: My intent here is the help good people who take their responsibilities toward metadata seriously from becoming victims of trolling or Twitter-hate, in case they are faced with a potentially controversial image. It is NOT to help forgers cover their tracks. (Evil doers will generally just strip ALL the metadata off their work anyway.) Please use this command for peaceful purposes!




Phil Harvey

Hi Carl,

I'm a bit too late with this suggestion, but there is a support file arg_files/iptcCore.args in the full ExifTool distribution that may be of some use to you.  To remove all XMP except standard IPTC you could do this:

exiftool -xmp:all= -tagsfromfile @ -@ iptcCore.args -struct FILE

(Adding -struct is necessary in this case to prevent the flattened tags specified in iptcCore.args from being generated because copying these may not preserve the hierarchy of structured tags.  Yes, metadata is complicated.)

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

StarGeek

Quote from: carlseibert on July 17, 2017, 03:07:47 PM(see this post for an explanation: http://www.carlseibert.com/macron-portrait-metadata/  )

One thing to take note of with regards to the above.  In the case of RAW files, EXIF data is not "largely useless", as removing it will mean that image becomes unviewable.
* 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).

StarGeek

Quote from: Phil Harvey on July 18, 2017, 10:47:33 AM
I'm a bit too late with this suggestion, but there is a support file arg_files/iptcCore.args in the full ExifTool distribution that may be of some use to you.

Dang it, how did I miss that.  I have a copy of that hidden away in an old exiftool directory, but somehow it didn't make it into my main directory.
* 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).

carlseibert

So here I am a year later, just now seeing Phil's reply......

.args files are way cool.

Thanks!