Metadata injection fails silently with non-standard groups present

Started by eleigh, July 03, 2020, 06:49:59 AM

Previous topic - Next topic

eleigh

I am working with a JPEG file that contains non-standard metadata groups (XMP-mbn and XMP-iX). An example is this public domain image from the Rijksmuseum:
https://lh3.ggpht.com/FkkMpQsDIyGGyfUGafaEKVcrXJXFDMfzDBuIU41XIg8nWGGEQwmHa1ouAL2Zhyl2yw4mBqwAlmUY1tULVdZoTN2QcA=s0

The following sequence of commands leaves the metadata untouched with no error messages, neither when setting values nor writing to the file:

my $exifTool = new Image::ExifTool;
$exifTool->SetNewValue('*');
($rv, $errStr) = $exifTool->SetNewValue('XMP-xmpRights:*', undef, Replace => 2);

[... various subsequent SetNewValue() calls ...]

$rv = $exifTool->WriteInfo($dest);


It seems the attempt to preserve the XMP-xmpRights group conflicts with having unrecognised XMP- groups? Should this not be handled explicitly, with an error and option to override?

Phil Harvey

This works for me on the command line, so I'm not sure why it isn't working for you:

> exiftool a.jpg "-xmp<=a.xmp"
    1 image files updated
> exiftool a.jpg -xmp:all -G1
[XMP-x]         XMP Toolkit                     : Image::ExifTool 12.01
[XMP-xx]        Testtag                         : this is a test
[XMP-xmpRights] Marked                          : True
[XMP-xmpRights] Usage Terms                     : All rights reserved no usage without express agreement in advance
> exiftool a.jpg -all= --xmp-xmprights:all
    1 image files updated
> exiftool a.jpg -xmp:all -G1
[XMP-x]         XMP Toolkit                     : Image::ExifTool 12.01
[XMP-xmpRights] Marked                          : True
[XMP-xmpRights] Usage Terms                     : All rights reserved no usage without express agreement in advance
> cat a.xmp
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.01'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:xx='http://test.org/xx/1.0/xmlns/'>
  <xx:testtag>this is a test</xx:testtag>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:xmpRights='http://ns.adobe.com/xap/1.0/rights/'>
  <xmpRights:Marked>True</xmpRights:Marked>
  <xmpRights:UsageTerms>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>All rights reserved no usage without express agreement in advance</rdf:li>
   </rdf:Alt>
  </xmpRights:UsageTerms>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

eleigh

I just tried this on the command line using Exiftool v12.01 on the example jpeg file linked above:

c:\bin\exiftool\exiftool input.jpg -xmp:all

XMP Toolkit                     : XMP toolkit 2.9-9, framework 1.6
Metadata Date                   : 2010:04:02 10:19:32Z
Tag                             : #MB%:{F813C3B4-5119-47D4-B7A2-71DAC806E359}S-DAM-1:%MB#
Changes                         : tag,2010-04-02T10:19:32Z,1,c


c:\bin\exiftool\exiftool input.jpg "-all= --xmprights:all"

Warning: [Minor] IPTC:ServiceIdentifier exceeds length limit (truncated) - input.jpg
    1 image files updated


c:\bin\exiftool\exiftool input.jpg -xmp:all

XMP Toolkit                     : XMP toolkit 2.9-9, framework 1.6
Metadata Date                   : 2010:04:02 10:19:32Z
Tag                             : #MB%:{F813C3B4-5119-47D4-B7A2-71DAC806E359}S-DAM-1:%MB#
Changes                         : tag,2010-04-02T10:19:32Z,1,c


The XMP tags have not been removed. If I run it without the --xmprights:all then all metadata is removed as expected.

StarGeek

Just a couple of notes

Quote from: eleigh on July 04, 2020, 08:17:08 AM
c:\bin\exiftool\exiftool input.jpg "-all= --xmprights:all"

The quotes are incorrect on this command. This will attempt to set every tag to a value of " --xmprights:all" (leading space included).  Which is why you get the IPTC:ServiceIdentifier exceeds length limit warning.  It's writing to IPTC (and EXIF) tags and not clearing any data.  The command you are trying to use is
exiftool input.jpg -all= --xmprights:all

But that also runs into the problem that the group name is incorrect.  I believe what you want to use is XMP-xmpRights,
exiftool input.jpg -all= --XMP-xmpRights:all

Finally, that example file gives a Can't handle XMP attribute 'rdf:ID' warning, which is why it won't update the XMP.  Adding the -m (ignoreMinorErrors) option will force an update.
"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

eleigh

Thanks @StarGeek for pointing out my typo and explaining the correction, which makes sense.

Going to back to my Perl project, what I hadn't expected is for WriteInfo to fail with a warning (rather than an error), so I hadn't checked the warning message.

I think it would be more consistent with conventions if:

Minor error/warning = Error [stopping execution]
minor error/warning = Warning [not stopping execution]

In that case Can't handle XMP attribute 'rdf:ID' would be upgraded to an error. The flag IgnoreMinorErrors would then be more accurate: i.e. ignore minor (ignorable) rather than fatal errors.

Phil Harvey

But if you were writing other types of metadata (eg. EXIF, IPTC) then they would have been written fine.  Upgrading the XMP warning to an error would break that.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).