Thread

Posted on Thu Mar 27 02:09:10 2008 by rogerhoward
Deleting all but a few tags
I've got a script which allows a user to delete all metadata from an image except the values of tags stored in a whitelist. I thought the exiftool invocation would be something as simple as: exiftool -all= --Creator --Copyright image.jpg Then I realized the docs make it clear that won't work - "Note that this will not exclude individual tags from a group delete. Instead, the tags must be recovered using the -TagsFromFile option". So I figured to use the -TagsFromFile option instead, something like: exiftool -all= -TagsFromFile image.jpg -Copyright -Creator image.jpg But in that case I get the following output: Warning: Error parsing XMP - image.jpg 1 image files updated And the resulting JPEG still appears to have all of it's metadata. In the end, I resorted to an ugly solution that involves three invocations of exiftool: 1. Use exiftool to read the tags I'm interested in keeping 2. Use exiftool -all= to remove all metadata 3. Use exiftool to add the tags I preserved in step 3 back to the file Is there a single step way of wiping all metadata except specific tags? I can live with some limitations - for instance, if some tags cannot be preserved individually. PS, love love love Exiftool. This is the first stumper I've had in several years. Best, R
Direct Responses: 7480 | Write a response
Posted on Thu Mar 27 13:56:01 2008 by exiftool in response to 7475
Re: Deleting all but a few tags
Sorry, this is my fault. It seems that I have introduced a bug in exiftool 7.18 that causes this problem when deleting all XMP and adding it back again in the same step. So you can either revert to version 7.17 or earlier, or wait a couple of days until I release version 7.23 which in which this bug will be fixed.

Thanks for pointing this out.

- Phil
Direct Responses: 7482 | Write a response
Posted on Thu Mar 27 15:20:16 2008 by exiftool in response to 7480
Re: Deleting all but a few tags
The bug fix was simple, so I decided to release the Perl version of 7.23 now instead of waiting. I have also added a test to make sure this doesn't get broken again.

Sorry for any inconvenience, and thanks again for reporting this.

- Phil
Direct Responses: 7483 | 7487 | Write a response
Posted on Thu Mar 27 16:11:15 2008 by rogerhoward in response to 7482
Re: Deleting all but a few tags
Hi Phil, Which of the methods I mentioned is the preferred route given the fix?
I'm assuming this:

exiftool -all= -TagsFromFile ./image.jpg -Copyright -Creator ./image.jpg

Cheers and thanks for the quick fix!

-Roger
Direct Responses: 7485 | 7524 | Write a response
Posted on Thu Mar 27 16:24:29 2008 by exiftool in response to 7483
Re: Deleting all but a few tags
Yes, that's the one. And you can use "-tagsfromfile @" to allow this command to be used on multiple files (or just to avoid having to type the file name twice).

- Phil
Write a response
Posted on Thu Mar 27 22:23:20 2008 by pauljsolomon in response to 7482
Re: Deleting all but a few tags
I downloaded the tar file for 7.23 because it is not yet avail for the mac. I followed the instructions for installation (perl Makefile.PLS, make, make test, sudo make install). No errors. When I run exiftool, It still reports that it is version 7.20. Am I missing a step?
Direct Responses: 7488 | Write a response
Posted on Fri Mar 28 01:20:37 2008 by exiftool in response to 7487
Re: Deleting all but a few tags
This note in the Installing documentation may help:

"(Note: The OS X installations above place exiftool and its "lib" directory in /usr/bin, while the standard Unix "make install" described below puts exiftool in /usr/bin and the individual libraries in /Library/Perl/#.#.#, where "#.#.#" is your Perl version. If both sets of libraries exist, /usr/bin/lib takes precedence for exiftool, but /Library/Perl/#.## is the default for any other Perl scripts.)"

So you should delete /usr/bin/lib (after confirming it contains only ExifTool files) if you want exiftool to use the modules installed with "make install".

- Phil
Write a response
Posted on Mon Mar 31 05:31:59 2008 by pauljsolomon in response to 7483
Re: Deleting all but a few tags
I am writing a script similar to the above to republish files (e.g. *.jpg) with some of the EXIF data and copyright data.

A few questions:

1. Is there an easier way to do this without looping thru all the files in the script (e.g. using the -r flag)?
2. The command below seems to produce unreadable canon raw (.cr2) files. What is wrong with this command for .cr2 files?

exiftool -all= \ -TagsFromFile @ \ -make \ -model \ -exposuretime \ -aperturevalue \ -flash \ -iso \ -lens \ -focallength \ -orientation \ -datetimeoriginal \ -copyright \ -copyrightNotice \ -Creator \ -usageterms \ -XMP-photoshop:authorsPosition \ -XMP-xmpRights:marked \ -CreatorContactInfoCiEmailWork \ -CreatorContactInfoCiTelWork \ original_file.jpg \ -o publish_file.jpg


thanks
-paul.
Direct Responses: 7531 | Write a response
Posted on Mon Mar 31 14:22:58 2008 by exiftool in response to 7524
Re: Deleting all but a few tags
Hi Paul,

With exiftool you should almost never have to loop through files yourself. You can change the -o option to something like -o %d%f_new.jpg to add "_new.jpg" to all of the file names, then instead of "original_file.jpg", use a directory name. Then all images in the directory will be rewritten. Or, a different way to do this is to use something like -o publish_dir/%f.jpg to write the new images with the original names to a different directory.

Your command doesn't work with CR2 images because you are effectively destroying all proprietary Canon information with -all=. Unfortunately some of this information is necessary for converting the image. In general, you have to be very careful about deleting information from RAW images. Also, you should never change the Make and Model tags in a RAW image because without this information the converters will not be able to properly parse the file.

- Phil
Direct Responses: 7535 | Write a response
Posted on Mon Mar 31 17:06:46 2008 by pauljsolomon in response to 7531
Re: Deleting all but a few tags
Awesome! Thanks so much for the help! Is there a place (maybe this forum?) that we can contribute scripts we've been working on? I can post some of mine if people are interested.
Direct Responses: 7536 | Write a response
Posted on Mon Mar 31 17:21:57 2008 by exiftool in response to 7535
Re: Deleting all but a few tags
Hi Paul,

Just post them here if you think they would be useful. People will search the forum and find them. Also, I realized I can simplify the syntax of my last -o example. You can just use -o DIR to output the modified images to a different directory (with the same file names).

- Phil
Write a response