ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: themanwho on January 08, 2011, 04:57:50 PM

Title: remove (sort of) duplicate tags...
Post by: themanwho on January 08, 2011, 04:57:50 PM
Hi!
I am stuck with some questionable XMP that contains pairs of tags that differ in case only, for example XMP-tiff:make and XMP-tiff:Make.  I would like to remove them both and write them back with the proper case.  A single call to $exiftool->SetNewValue ( 'make' => undef ); or $exiftool->SetNewValue ( 'Make' => undef ); removes only the first instance -- regardless of case.  What I wound up doing is something like:


        $exiftool->SetNewValue ( 'make' => undef );
        $exiftool->WriteInfo ( $source );
        $exiftool->SetNewValue ( 'make' => undef );
        $exiftool->WriteInfo ( $source );

which successfully removes both.  This seems a little awkward though, and I suspect there my be a better way to do it?  I have also tried:

        $exiftool->SetNewValue ( 'make' => [undef,undef] );

and again, it removes only the first occurring instance.

Is there a more idiomatic way of accomplishing my goal?

Thanks in Advance,
Bill

Title: Re: remove (sort of) duplicate tags...
Post by: Phil Harvey on January 08, 2011, 08:49:10 PM
Hi Bill,

Would I be correct in assuming that the questionable XMP was written by a Microsoft product?  They have an absolutely terrible track record when it comes to using the wrong case for XMP tags, and I have already added a patch to ExifTool specifically to prevent the exact type of problem you are seeing now.

Unfortunately I can't think of any way to coax ExifTool to remove two tags when only one may be specified.  It would require yet another patch to handle this type of peculiar file, and since this is the first time I have heard of this problem, and the work-around isn't really too painful, I don't think the patch is worthwhile in this case.

- Phil

P.S. BTW, you can remove the 2nd call to SetNewValue() since the settings are preserved through WriteInfo() calls.
Title: Re: remove (sort of) duplicate tags...
Post by: themanwho on January 09, 2011, 03:50:55 PM
Well, I'm not sure --  I was handed this collection of images rather blindly, but it wouldn't surprise me if you are correct.

No problem here, so long as I can get the job done one way or another.  Thanks for the heads-up on removing one line of code anyway.  I will try simply:


        $exiftool->SetNewValue ( 'make' => undef );
        $exiftool->WriteInfo ( $source );
        $exiftool->WriteInfo ( $source );

correct?

Thanks a million,
Bill
Title: Re: remove (sort of) duplicate tags...
Post by: Phil Harvey on January 10, 2011, 07:09:12 AM
Hi Bill,

Yes, that's the idea.

- Phil