Author Topic: Overriding default definition of existing tag  (Read 136 times)

mazeckenrode

  • Jr. Member
  • **
  • Posts: 28
Overriding default definition of existing tag
« on: June 30, 2020, 02:18:05 PM »
Trying to override the default definition of XMP:UserComment as cautiously advised by Phil here, but not completely clear how to do it. The example config file includes the following user-defined XMP tag:

Code: [Select]
# XMP tags may be added to existing namespaces:
     'Image::ExifTool::XMP::xmp' => {
         # Example 5.  XMP-xmp:NewXMPxmpTag
         NewXMPxmpTag => { Groups => { 2 => 'Author' } },
         # add more user-defined XMP-xmp tags here...
     },

I notice that in the example above, no writeable format is specified for the new tag. Does it become string by default when not specified?

Also, may I please have an explanation for { Groups => { 2 => 'Author' } }? It looks to me like maybe 'Author' is a brief description of the new tag’s intended content? Is there a list of allowable values, or can it be anything?

Seeing that I’m overriding XMP:UserComment, assuming my assumptions so far are correct, I’m thinking my own code should be something along the lines of:

Code: [Select]
    'Image::ExifTool::XMP' => {
        UserComment => { Writable => 'string', Groups => { 2 => 'Comment' } },
    },

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16502
    • ExifTool Home Page
Re: Overriding default definition of existing tag
« Reply #1 on: June 30, 2020, 03:18:20 PM »
I notice that in the example above, no writeable format is specified for the new tag. Does it become string by default when not specified?

Yes.

Quote
Also, may I please have an explanation for { Groups => { 2 => 'Author' } }? It looks to me like maybe 'Author' is a brief description of the new tag%u2019s intended content? Is there a list of allowable values, or can it be anything?

Here is a list of group names.

Quote
Seeing that I%u2019m overriding XMP:UserComment, assuming my assumptions so far are correct, I%u2019m thinking my own code should be something along the lines of:

Code: [Select]
    'Image::ExifTool::XMP' => {
        UserComment => { Writable => 'string', Groups => { 2 => 'Comment' } },
    },

Close, but XMP:UserComment is in XMP "exif" namespace.  So it should be:

Code: [Select]
    'Image::ExifTool::XMP::exif' => {
        UserComment => { },
    },

The default Writable is 'string', and the default family 2 group name is Image for exif tags (since the UserComment refers to the image), so these don't need to be specified.  (You would have to look at the source code to find out about the default family 2 group name.)

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

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3641
Re: Overriding default definition of existing tag
« Reply #2 on: June 30, 2020, 03:20:19 PM »
Any particular reason that you want to do this?  As I mentioned here, it's not something you should worry about.  Any program that reads it is going to treat it as a string unless an alternative language is specifically asked for, and that would only be in cases that the software supports lang-alt.

There are a several common XMP tags that are lang-alt, including some you are probably already using such as Description, Title, and Rights.

If you redefine the tag, it might make it so that no software other than exiftool can read it.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16502
    • ExifTool Home Page
Re: Overriding default definition of existing tag
« Reply #3 on: June 30, 2020, 03:22:58 PM »
StarGeek is correct.  There should be no reason to change this.  But you asked so I answered.

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

mazeckenrode

  • Jr. Member
  • **
  • Posts: 28
Re: Overriding default definition of existing tag
« Reply #4 on: June 30, 2020, 05:55:33 PM »
So it should be:

Code: [Select]
    'Image::ExifTool::XMP::exif' => {
        UserComment => { },
    },

Thanks, Phil, for the corrections and clarifications.

Any particular reason that you want to do this? As I mentioned… it’s not something you should worry about. Any program that reads it is going to treat it as a string unless an alternative language is specifically asked for…

Unfortunately, what I currently have to deal with is that Directory Opus won’t read XMP:UserComment as created or modified by ExifTool. As I see it, though I’m certainly not the expert here, the most likely explanation is that DOpus expects it to be a plain string, since DOpus itself (or Exiv2 library, rather) writes it that way, but ExifTool has turned it into a lang-alt tag upon modification. I was hoping that by overriding its normal definition as lang-alt to just be a regular string, it might remain readable by DOpus after ExifTool was used to change its contents. Of course, this might be a losing battle, but I thought I’d give it a try. As always, any other insight is welcome.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3641
Re: Overriding default definition of existing tag
« Reply #5 on: June 30, 2020, 08:52:42 PM »
the most likely explanation is that DOpus expects it to be a plain string, since DOpus itself (or Exiv2 library, rather) writes it that way,

I doubt that's the problem.

I used the exiv2 command line program to write the XMP:UserComment and it writes a lang-alt tag.  Here is the XMP for both exiftool and exiv2.  Though it has been reformatted, the basics are the same.  The quoting is different though.  Double quotes in the exiv2 output and single quotes with exiftool.

Code: [Select]
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:exif="http://ns.adobe.com/exif/1.0/">
<exif:UserComment>
<rdf:Alt>
<rdf:li xml:lang="x-default">new Test Comment</rdf:li>
</rdf:Alt>
</exif:UserComment>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>

Code: [Select]
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<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:exif='http://ns.adobe.com/exif/1.0/'>
<exif:UserComment>
<rdf:Alt>
<rdf:li xml:lang='x-default'>test of usercomment</rdf:li>
</rdf:Alt>
</exif:UserComment>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mazeckenrode

  • Jr. Member
  • **
  • Posts: 28
Re: Overriding default definition of existing tag
« Reply #6 on: July 01, 2020, 08:39:27 AM »
Here is the XMP for both exiftool and exiv2. Though it has been reformatted, the basics are the same. The quoting is different though.

Does the difference in quoting account for why ExifTool gives me [minor] Fixed incorrect list type for XMP-exif:UserComment when I use it to modify that tag after it was previously written by Directory Opus? Does the sample DOpus-populated file I uploaded here tell us anything useful?

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3641
Re: Overriding default definition of existing tag
« Reply #7 on: July 01, 2020, 11:41:48 AM »
Code: [Select]
   <exif:UserComment>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">&lt;comment&gt;</rdf:li>
    </rdf:Alt>
   </exif:UserComment>

Also a lang-alt tag.

But I don't get that error when I modify the UserComment on that file.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mazeckenrode

  • Jr. Member
  • **
  • Posts: 28
Re: Overriding default definition of existing tag
« Reply #8 on: July 01, 2020, 09:35:00 PM »
But I don't get that error when I modify the UserComment on that file.

First, let’s verify that we’re referring to the same tag. When I use Directory Opus to write what it simply refers to as “Comment”, it writes that same value to both EXIF:XPComment and XMP:UserComment. It does not write to EXIF:UserComment. Your XML output in your last two posts all say </exif:UserComment>, though other lines in the XML here do also refer to XMP. Just want to make sure that the example in your last post is, in fact XMP:UserComment, especially since not only UserComment refers to more than one possible tag, but there seems to be multiple ways to refer to just one of them. (And what on earth is up with that, anyway?)

In any case, I’ve now done multiple tests of modifying XMP:UserComment using ExifTool, after having initially written it using Directory Opus, and I’m getting Warning: [minor] Fixed incorrect list type for XMP-exif:UserComment almost every time, though not with that file that I’d previously uploaded, although I can’t say for certain at this point that I hadn’t maybe done something else with that file prior to zipping and uploading. Please try the file “1_DOpus_MAZE_Tags.png” in the newly uploaded attachment.

On the positive side, I no longer seem to be able to duplicate the ExifTool-modified version of that tag not being read by DOpus. If it happens again, and I actually manage to glean some useful information from it, I’ll be in touch.

Attached: “Comment Test.7z” (1,561)

Contents:

“Comment Test\”
  “0_Empty.png” (197) [1 x 1 x 1]
  “1_DOpus_MAZE_Tags.png” (4,049) [1 x 1 x 1]

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3641
Re: Overriding default definition of existing tag
« Reply #9 on: July 01, 2020, 10:50:10 PM »
Your XML output in your last two posts all say </exif:UserComment>, though other lines in the XML here do also refer to XMP. Just want to make sure that the example in your last post is, in fact XMP:UserComment, especially since not only UserComment refers to more than one possible tag,

The fact that you can actually read it means it is XMP, as XMP is based upon XML.  The full group name for the tag is XMP-exif:UserComment.  See the XMP-exif tag listing

The EXIF group (and IPTC IIM) are not readily human readable and doesn't include the tag names in the raw data.  See EXIF tag page which has some details at the top.

Quote
but there seems to be multiple ways to refer to just one of them. (And what on earth is up with that, anyway?)

It has to do with the hierarchy that exiftool groups tags by.  In the case of the XMP version of UserComment, it can be referred to by family 0 "Information Type" which would be XMP or by the family 1 "Specific Location" which would be  XMP-exif.  If it already exists, then it can also be referred to by just UserComment, but if it doesn't already exists, then UserComment will refer to the EXIF tag of that name.  See the Tag Names and following sections of the main exiftool page.

Quote
I’m getting Warning: [minor] Fixed incorrect list type for XMP-exif:UserComment almost every time,

Please try the file “1_DOpus_MAZE_Tags.png” in the newly uploaded attachment.

Definitely different.  It does look like it's not being written correctly.  Raw XMP isn't my strong suit, so maybe Phil can comment on it.
Code: [Select]
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.1.2">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
    xmlns:xmp="http://ns.adobe.com/xap/1.0/"
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
   photoshop:Instructions="&lt;instructions&gt;"
   dc:title="&lt;title&gt;"
   tiff:Make="&lt;camera make&gt;"
   tiff:Model="&lt;camera model&gt;"
   xmp:CreatorTool="&lt;creation software&gt;"
   xmp:CreateDate="2020:06:14 18:29:30"
   exif:DateTimeOriginal="1900:01:01 00:00:00"
   exif:UserComment="&lt;comment&gt;"
   aux:Lens="&lt;lens model&gt;">
   <dc:subject>
    <rdf:Bag>
     <rdf:li>&lt;tags&gt;</rdf:li>
     <rdf:li>&lt;tag1&gt;</rdf:li>
     <rdf:li>&lt;tag2&gt;</rdf:li>
     <rdf:li>&lt;tag3&gt;</rdf:li>
     <rdf:li>&lt;tag4&gt;</rdf:li>
    </rdf:Bag>
   </dc:subject>
  </rdf:Description>
 </rdf:RDF>
</x:xmpmeta>             
<?xpacket end="w"?>

Quote
On the positive side, I no longer seem to be able to duplicate the ExifTool-modified version of that tag not being read by DOpus. If it happens again, and I actually manage to glean some useful information from it, I’ll be in touch.

Did the file that couldn't be read properly have a lot of XMP data in it?  The only other thing I can think of would be if it had a lot of data and had to be split between two jpg blocks.

Another thing to try might be to see if you can update the exiv2 .dll from the exiv2 website.  At least I'm assuming that DO relies upon an external library rather that embedding the code into the main file.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mazeckenrode

  • Jr. Member
  • **
  • Posts: 28
Re: Overriding default definition of existing tag
« Reply #10 on: Today at 11:26:16 AM »
Did the file that couldn’t be read properly have a lot of XMP data in it? The only other thing I can think of would be if it had a lot of data and had to be split between two jpg blocks.

How much is a lot, and do jpg blocks exist in PNG files? All of the files I’m dealing with right now are PNGs.

I set all of the following DOpus metadata fields in one file:

Authors
Copyright
Description
Instructions
Subject
Title
Camera make
Camera model
Creation software
Date digitized
Date taken
GPS Altitude
GPS Latitude
GPS Longitude
Lens make
Lens model
Rotation
Comment
Tags


As previously detailed, values entered in most or all of those fields go to multiple tag groups/names, including EXIF, XMP and IPTC. Let me know if you need a complete list, but you should be able to find out from “1_DOpus_MAZE_Tags.png” in my previously uploaded file.

For all of the string fields (all but the two dates, GPS and Rotation), I entered lengthy repeating (up to 30x) strings such as:

<comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment><comment>

…though shorter, but still repeating strings for a handful (3–5x each for Camera & Lens make/model, 10x each for Authors/Copyright/Creation software).

After using using ExifTool to write a similarly repeating <new comment> string to EXIF:XPComment and XMP:UserComment, DOpus remained able to read and display the comment.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3641
Re: Overriding default definition of existing tag
« Reply #11 on: Today at 12:03:27 PM »
How much is a lot, and do jpg blocks exist in PNG files? All of the files I’m dealing with right now are PNGs.

Oops, forgot about that.  "A lot" would be 64kb, which is the maximum size for a jpeg data block.  In those cases the data needs to be split.  It's something that has come up before with apps that can't deal with it.

Since you're using PNGs, it doesn't apply here.

Another possibly hit me this morning and that has to do with how old the exiv2 library may be using.

The DO acknowledgements page gives the latest year under the exiv2 entry as 2014.  At that time, there wasn't a standard for putting EXIF data in PNG.  But there was a workaround for it that was supported by ImageMagick, exiv2, and exiftool. 

A few years ago (2017 I think), a standard to put EXIF data in a PNG was finally written, which is now the default (I think) for exiftool.  But if DO is using an older exiv2 library, it would be able to read EXIF data in a PNG if it was written according to the new spec.

This leads to the XPComment tag, which is part of the EXIF group.  If EXIF data didn't already exist in the file, when exiftool write it, it will be to the new spot.  I don't remember offhand what happens if exiftool is updating EXIF data that was written the old way.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.