News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Adding a custom attribute instead of a custom tag

Started by csp, February 26, 2020, 01:24:29 AM

Previous topic - Next topic

csp

First of all thanks to anyone willing to read/help with the below, I've been pulling my hair out trying to solve this problem with Exiftool but I've finally succumbed to asking for help.

I'm trying to add a custom attribute (at least this is what I would call it due to working with XML/HTML), however it appears I'm not understanding the documentation or it's simply not a valid case (perhaps?), for example, using my custom config I get the following output:


<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
  <xmp:CustomAttribute>test</xmp:CustomAttribute>
</rdf:Description>
</rdf:RDF>


Here is my config:


%Image::ExifTool::UserDefined = (
  'Image::ExifTool::XMP::xmp' => {
     CustomAttribute => {
         Writable => 'string',
     },
  },
);   
1; # end



However, I'm trying to achieve the following:


<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'
  xmp:CustomAttribute='test'>
</rdf:Description>
</rdf:RDF>


I've tried several different configs which result in the same output, or simply error due to invalid config files/unwritable tags.

Is this possible with exiftool?

StarGeek

I think what you want is to add -api Compact=Shorthand.

See this post for an example.  If I recall correctly, the xmpshorthand used in that post has been replaced (see this thread for details) by the -api Compact option.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Yes.  -api XMPShorthand is now -api Compact=Shorthand, but the old option still works.

- 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 ($).

csp

Thank you very much StarGeek and Phil, admittedly I did see this in the documentation (when searching for XMP) however thought it was only for visual spacing and such.

Phil Harvey

It is just visual.  The actual structure of the underlying XMP doesn't change with this option.  It is only the format of the serialization that is different.

- 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 ($).