Strip all metadata except some, and add a value for some fields

Started by Hashim, October 02, 2023, 01:20:17 PM

Previous topic - Next topic

Hashim

Hi Phil

Firstly, thanks for a great piece of software and for the time you and other contributors spend maintaining it.

I have a directory structure that contains a lot of JPEG/JPG, PNG, SVG, and WEBP images in several subdirectories. I want to strip all metadata from these image files except anything that would be necessary for the images to function (colour profiles, orientation, etc.) as well as the date. I then want to change each one's OwnerName and Artist fields to a given string.

Piecing together info from the docs I've come up with the following command:

exiftool -a -r -overwrite_original -ext JPG -ext JPEG -ext PNG -ext SVG -ext WEBP -all=
--icc_profile:all -OwnerName="Example.com" -Artist="Example.com" -tagsfromfile @ -ColorSpaceTags  myfolder1/myfolder2

I think this contains everything I want to do except leave the dates intact, as I'm unsure which of the data fields would be best to use.

Is this command suitable for my needs? Do the other file types maybe require more delicate handling that it would be safer to process them separately from the JPGs?

If this command would work, which of the EXIF, XMP or IPTC date tags should I be leaving in?

Lastly, is there any value in adding

validate -warning -error

to this command?

StarGeek

Quote from: Hashim on October 02, 2023, 01:20:17 PMI have a directory structure that contains a lot of JPEG/JPG, PNG, SVG, and WEBP images

You can remove SVG files from your command, as they are read only. See the Supported File Types table.

QuoteI think this contains everything I want to do except leave the dates intact, as I'm unsure which of the data fields would be best to use.

At the very least, you would use the AllDates shortcut, which contains the three most common EXIF timestamps, CreateDate, DateTimeOriginal, and ModifyDate. That will cover most situations.  You could use this command to look at all the date/time tags in the file and decide if there are any other ones you might want to copy.
exiftool -time:all -G1 -a -s /path/to/files/

QuoteIs this command suitable for my needs?

You mentioned Orientation so you probably want to put that in right after ColorSpaceTags.  You would also put AllDates here
-tagsfromfile @ -ColorSpaceTags -AllDates -Orientation

QuoteDo the other file types maybe require more delicate handling that it would be safer to process them separately from the JPGs?

Not for the file types you listed.  Tiff and RAW (CR2, NEF, ARW, etc) would need special handling, as removing EXIF data can make the file unrenderable.

QuoteLastly, is there any value in adding

validate -warning -error

Not really. Your command removes the EXIF block but if you add AllDates, then a minimal EXIF block will be created.  Validate will then return a bunch of warnings for EXIF tags that are required by the spec, but don't actually affect viewing the image.

If there are any warnings or errors, they will show up in the output on separate lines anyway.  Also, these options are for when you are reading data from a file.  When you are writing data, you'll get a Ignored superfluous tag names or invalid options warning.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Hashim

Perfect, thanks for the quick and enlightening answer.

QuoteAt the very least, you would use the AllDates shortcut, which contains the three most common EXIF timestamps, CreateDate, DateTimeOriginal, and ModifyDate. That will cover most situations.  You could use this command to look at all the date/time tags in the file and decide if there are any other ones you might want to copy.
exiftool -time:all -G1 -a -s /path/to/files/

Are these what Windows/most programs use to extract the time date? I notice the File Modification and File Creation tags are not in the list of EXIF tags, yet they do exist because even the SVGs I've looked at seem to contain them. How would I keep those tags?

Quote from: StarGeek on October 02, 2023, 02:04:50 PMYou can remove SVG files from your command, as they are read only. See the Supported File Types table.

Interesting, I didn't know SVG tools don't support standard EXIF/XMP/ITPC metadata, but doing some more research this does seem to be the case. How about for the above-mentioned File* metadata tags, what's going on with those?

StarGeek

Quote from: Hashim on October 02, 2023, 03:17:01 PMAre these what Windows/most programs use to extract the time date?

These are the three main tags that almost all programs will read.

QuoteI notice the File Modification and File Creation tags are not in the list of EXIF tags, yet they do exist because even the SVGs I've looked at seem to contain them. How would I keep those tags?

That's because they are not EXIF tags, they are part of the file system.  File system tags are not embedded in the file and are fragile.  The FileModifyDate will change any time the file is edited and neither of these tags exist if the file is uploaded via http(s).

FileCreateDate won't change unless it is copied to another computer, maybe, depending upon how it is copied.  You can add the -P (-preserve) option to your command to keep the FileModifyDate the same, but it is still subject to change from other programs.  Additionally, some backup programs will skip files when the FileModifyDate has not been changed.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Hashim

That's perfect, thank you. Here's the current command I have for what I'm planning to do here:

exiftool -P -a -r -overwrite_original -ext JPG -ext JPEG -ext PNG -ext WEBP -all= --icc_profile:all -OwnerName="Example.com" -Artist="Example.com" -tagsfromfile @ -ColorSpaceTags  -Orientation -AllDates myfolder/

Is there anything in there that doesn't need to be or anything that isn't there and should be? For example, is --icc_profile:all still needed with ColorSpaceTags, or is it redundant?


StarGeek

It's redundant. The ColorSpaceTags shortcut covers the ICC_Profile and a few other tags.  See the Shortcuts tags page.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Hashim

Doing some preliminary tests with one of each file type, I've noticed that OwnerName has no effect on Windows Explorer's Owner field for JPEGs, and Artist has no effect on Authors, Creators or similar fields for PNGs and WEBPs (but does for JPEGs). Any idea what tags I should be targeting instead here, or at least what the most commonly used tags are for this kind of thing?

StarGeek

First, understand that what Windows lists under Properties->Details are not tag names, they are properties.  Windows can read multiple tags when it fills a property.

See this post for a list of what tags are read to fill various properties.

Windows has a lot of properties and not all of them apply to every filetype.  When you right click->Properties->Details does an entry for "Owner" show up? I don't have a listing when I look at a jpg. In most cases, if it doesn't show up under the details tab, even with a blank entry, then that property doesn't apply to that filetype.

When I write to EXIF:Artist, the "Authors" property displays the value there.  If you are looking at the Details tab, make sure you close/reopen it, as that window is not updated automatically.

Windows only reads one tag in PNG files and that is PNG:CreationTime which it uses as "Date Taken".  It doesn't read any other data in a PNG file.

Windows will read some data from a webp (see the above link) but also lists properties that don't seem to be filled from any tag.  It's been 6 months since I last checked, so I'll have to see about doing an update.

I have an exiftool ARGS file in this post that will fill over 1,400 tags and this is what I use to check to see what tags Windows (and other programs) will read.  You can add the data to any file type you want to test with
exiftool -@ * MetadataTestFile.args Testfile.jpg

Though this is another thing I need to update, as exiftool has added a bunch of new tags since I last updated it.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Hashim

Quote from: StarGeek on October 03, 2023, 12:50:34 PMFirst, understand that what Windows lists under Properties->Details are not tag names, they are properties.  Windows can read multiple tags when it fills a property.

See this post for a list of what tags are read to fill various properties.

Windows has a lot of properties and not all of them apply to every filetype.  When you right click->Properties->Details does an entry for "Owner" show up? I don't have a listing when I look at a jpg. In most cases, if it doesn't show up under the details tab, even with a blank entry, then that property doesn't apply to that filetype.

When I write to EXIF:Artist, the "Authors" property displays the value there.  If you are looking at the Details tab, make sure you close/reopen it, as that window is not updated automatically.

Windows only reads one tag in PNG files and that is PNG:CreationTime which it uses as "Date Taken".  It doesn't read any other data in a PNG file.

Windows will read some data from a webp (see the above link) but also lists properties that don't seem to be filled from any tag.  It's been 6 months since I last checked, so I'll have to see about doing an update.

I have an exiftool ARGS file in this post that will fill over 1,400 tags and this is what I use to check to see what tags Windows (and other programs) will read.  You can add the data to any file type you want to test with
exiftool -@ * MetadataTestFile.args Testfile.jpg

Though this is another thing I need to update, as exiftool has added a bunch of new tags since I last updated it.

I see, so those tags simply don't exist for PNG or WEBP images (in Windows). I did check out that post but couldn't find an entry for Owner or OwnerName. Owner does show up under File for all of the files, although I've always assumed that to be an incomplete list and usually try enabling more columns using the Choose Details modal in Windows Explorer. I was actually mistaken a little here, OwnerName doesn't seem to change anything at all, on JPEGs, PNGs or WEBPs - Owner is the same for all files and folders in a directory, which is the name of the PC followed by my user account name - by the looks of it that's referring to the permissions owner and has nothing to do with OwnerName.

StarGeek

Quote from: Hashim on October 03, 2023, 01:06:52 PMI see, so those tags simply don't exist for PNG or WEBP images (in Windows).

No, the Properties don't exist for those files.  Windows Properties are not Tags (made more confusing by having a a Windows Property name "Tags").  For PNGs, there is only one property read from the file tags, but there are some for a webp, which seems to include a lot of the EXIF tags.

QuoteI did check out that post but couldn't find an entry for Owner or OwnerName. Owner does show up under File for all of the files

I see what you're looking at now. None of the Windows properties under the Files heading are tags in the file, they are properties of the file system.  In the case of Owner, that is the user name of the Windows account that owns the file.  For example, open up the C:\Windows directory and check out the Owner of some of those files.  You'll find SYSTEM, Administrators, TrustedInstaller, etc.  These are handled under Properties->Security tab.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype