[Originally posted by 00coday on 2006-10-23 23:45:07-07]I am trying to clear all IPTC/XMP/EXIF data from an image and write in only the information I want. I am using the following to clear the metadata
$exifTool->SetNewGroups('XMP');
$exifTool->SetNewValue('XMP:all' => undef);
$exifTool->SetNewGroups('IPTC');
$exifTool->SetNewValue('IPTC:all' => undef);
$exifTool->SetNewGroups('EXIF');
$exifTool->SetNewValue('EXIF:all' => undef);
$update=$exifTool-> WriteInfo("$basedir\\@record[1].jpg","$basedir\\@record[1]x.jpg");
and it works great. I then rename the file back to the original. The problem comes when I try to write back to the file. I am using:
$exifTool-> SetNewGroups('IPTC');
$exifTool-> SetNewValue('IPTC:ObjectName' => 'test data');
$update=$exifTool-> WriteInfo("$basedir\\$record[1].jpg","$basedir\\$record[1]x.jpg",'IPTC');
Neither perl or ExifTool report an error, but no data is written to the file. I am assuming that clearing the data the way I am will actually remove the spots in the file where it is supposed to reside, so there is nowhere to write to. I tried using the following:
$exifTool->SetNewGroups('XMP');
$exifTool->SetNewValue('XMP:all' => '');
$exifTool->SetNewGroups('IPTC');
$exifTool->SetNewValue('IPTC:all' => '');
$exifTool->SetNewGroups('EXIF');
$exifTool->SetNewValue('EXIF:all' => '');
$update=$exifTool->WriteInfo("$basedir\\@record[1].jpg","$basedir\\@record[1]x.jpg");
but I get a "Can't set value for all tags" error which comes from the date fields. Any thoughts on how to quickly clear all IPTC-XMP-EXIF fields without having to do them one by one and still be able to write to the resulting file?
[Originally posted by exiftool on 2006-10-24 12:22:34-07](Gotta watch using that back button in the browser-- you posted your message 4 times.

)
What you are doing will work. Well, it should work, and it does work for me. (You _are_ using ExifTool 6.40
or later, right?)
ExifTool will add back the necessary "spots" in the file to write the specified information. One thing though:
Your calls to SetNewGroups() have no effect because you are providing a specific group for writing the information.
The SetNewGroups() only sets the default group priorities if you call SetNewValue() with a group-less tag.
I just tried this code snippet here, and it works fine:
$exifTool->SetNewValue('iptc:all' => undef);
$exifTool->SetNewValue('xmp:all' => undef);
$exifTool->SetNewValue('exif:all' => undef);
$exifTool->SetNewValue('iptc:objectname' => 'test data');
$exifTool->WriteInfo('src.jpg', 'dst.jpg');
Note that you must be using ExifTool 6.40 or later for this to work, since in earlier versions
the delete operation always took precedence, and this type of operation would have to be
performed in two steps.
Your calls to SetNewValue('EXIF:all' => ''), etc won't work, because this would attempt to write
all EXIF tags with an empty value, which is very different from deleting the tags.
- Phil