Deleting all but a few tags

Started by Archive, May 12, 2010, 08:54:18 AM

Previous topic - Next topic

Archive

[Originally posted by rogerhoward on 2008-03-27 00:09:10-07]

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

Archive

[Originally posted by exiftool on 2008-03-27 11:56:01-07]

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

Archive

[Originally posted by exiftool on 2008-03-27 13:20:16-07]

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

Archive

[Originally posted by rogerhoward on 2008-03-27 14:11:15-07]

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

Archive

[Originally posted by exiftool on 2008-03-27 14:24:29-07]

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

Archive

[Originally posted by pauljsolomon on 2008-03-27 20:23:20-07]

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?

Archive

[Originally posted by exiftool on 2008-03-27 23:20:37-07]

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

Archive

[Originally posted by pauljsolomon on 2008-03-31 02:31:59-07]

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?

Code:
   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.

Archive

[Originally posted by exiftool on 2008-03-31 11:22:58-07]

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

Archive

[Originally posted by pauljsolomon on 2008-03-31 14:06:46-07]

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.

Archive

[Originally posted by exiftool on 2008-03-31 14:21:57-07]

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