ExifTool Forum

General => Metadata => Topic started by: hvdwolf on September 03, 2020, 04:46:55 AM

Title: custom metadata tags and aliases
Post by: hvdwolf on September 03, 2020, 04:46:55 AM
For my jExifToolGUI (JTG) I am adding new functionality where users can simply define their own combination of tags to use, but also to use custom tags that do not exist, by using a custom config that the user has to specify (and JTG will copy it to its datadirectory for future use).  When using the user "custom tag combination set", JTG will also use the custom cfg belong to it via the '-config <path_to>/custom.cfg'.
So with one of the users who needs special tags for "the museum world", I created a custom config based on this xml structure (https://gist.github.com/anarchivist/826364).

I named it isadg-struct.cfg. See attached. I works great from JTG (but still in beta).
However, you get really long "flat" tags, like xmp-isadg:AlliedmaterialsExistencelocationoriginals

So for that reason I wanted to create aliases.
I just added the first 3 tags as
%Image::ExifTool::UserDefined::Shortcuts = (
    Reference => 'IdentityReference',
    Title => 'IdentityTitle',
    Date => 'IdentityDate',
);


But only the first one 'Reference' is recognized. Changing the order, like putting it as last one in my list of aliases, doesn't change it. Only Reference is recognized.

Am I doing something wrong?
Note: I also created an isadg.cfg as flat tag tags (see attached as isadg.cfg) and this one works just as well, but for the aliases it doesn't change a thing. Only the Reference alias is recognized.

(I used the standard Ubuntu 10.80 exiftool and the downloaded 12.05 exiftool)

Title: Re: custom metadata tags and aliases
Post by: StarGeek on September 03, 2020, 11:11:16 AM
This is something I've been meaning to dig in to, but haven't had the time.  Phil should be back in a couple of days, so he'll be able to answer then.
Title: Re: custom metadata tags and aliases
Post by: StarGeek on September 03, 2020, 11:26:41 AM
And I figured it out.

I took a look at the CreatorContactInfo tag setup in the source XMP.pm and it's extremely simple.  You take the normal output name and give it Flat and Name options.  For example, your Alliedmaterials tag

    Alliedmaterials => {
        Struct => {
            Existencelocationoriginals => { Writable => 'string' },
            Existencelocationcopies => { Writable => 'string' },
            Relatedunits => { Writable => 'string' },
            Publication => { Writable => 'string' },
        },
    },
AlliedmaterialsExistencelocationcopies => { Flat => 1, Name => 'AmExLocCop' },
AlliedmaterialsExistencelocationoriginals => { Flat => 1, Name => 'AmExLocOr' },
AlliedmaterialsPublication => { Flat => 1, Name => 'AmExPub' },
AlliedmaterialsRelatedunits => { Flat => 1, Name => 'AmExReUn' },


In this case, the new tag names are
AmExLocCop
AmExLocOr
AmExPub
AmExReUn
Title: Re: custom metadata tags and aliases
Post by: hvdwolf on September 03, 2020, 12:32:34 PM
Thanks a lot!

That does indeed work flawlessly, also from my program.
Title: Re: custom metadata tags and aliases
Post by: hvdwolf on September 13, 2020, 02:40:39 PM
Actually it does not really work.
Like in your example AlliedmaterialsExistencelocationcopies => { Flat => 1, Name => 'AmExLocCop' },

I can then indeed use AmExLocCop to write the tag, but no longer AlliedmaterialsExistencelocationcopies

And with reading I  can't use AmExLocCop, but can only use AlliedmaterialsExistencelocationcopies to read the value.

This is not what I want.
And I still can't use the alias either.

(being on holiday it took a bit longer to further test this and come back on it)
Title: Re: custom metadata tags and aliases
Post by: Phil Harvey on September 13, 2020, 02:42:01 PM
You need to use the config file when reading as well if you want to use the AmExLocCop tag name.

- Phil
Title: Re: custom metadata tags and aliases
Post by: hvdwolf on September 13, 2020, 03:16:44 PM
Quote from: Phil Harvey on September 13, 2020, 02:42:01 PM
You need to use the config file when reading as well if you want to use the AmExLocCop tag name.
Indeed. Thanks (and after all so logical)


But like also mentioned:
Like in the example AlliedmaterialsExistencelocationcopies => { Flat => 1, Name => 'AmExLocCop' },

I can then indeed use AmExLocCop to write the tag, but no longer AlliedmaterialsExistencelocationcopies

Why?
Title: Re: custom metadata tags and aliases
Post by: Phil Harvey on September 13, 2020, 11:03:13 PM
Because each tag has one name.  You can make an alias using the Shortcuts feature if you want to refer to a tag by two names.

- Phil
Title: Re: custom metadata tags and aliases
Post by: hvdwolf on September 14, 2020, 04:11:18 AM
Thanks, but that is how I started (1st post) but could not make it work. Then Stargeek pointed me into another direction, but unfortunately that didn't work either (thanks anyway for putting in the time to help me).

Part of my cfg file is
    Identity => {
        Struct => {
            Reference => { Writable => 'string' },
            Title => { Writable => 'string' },
            Date => { Writable => 'string' },
            DescriptionLevel => { Writable => 'string' },
            Extent => { Writable => 'string' },
        },
    },


Then at the bottom of my cfg file I did the
%Image::ExifTool::UserDefined::Shortcuts = (
    Reference => 'IdentityReference',
    Title => 'IdentityTitle',
    Date => 'IdentityDate',
);
, but like mentioned: Only the "Reference" shortcut works. Not the other ones.
What am I doing wrong?
Title: Re: custom metadata tags and aliases
Post by: StarGeek on September 14, 2020, 11:10:49 AM
Quote from: hvdwolf on September 14, 2020, 04:11:18 AMOnly the "Reference" shortcut works. Not the other ones.
What am I doing wrong?

Probably the fact that there already exists Title and Date tags.
C:\>exiftool -g1 -a -s -title -date y:\!temp\Test4.jpg
---- XMP-dc ----
Date                            : 2020:09:14 08:08:30-07:00
Title                           : test
Title: Re: custom metadata tags and aliases
Post by: Phil Harvey on September 14, 2020, 11:21:43 AM
/me is confused again...

I thought we were just talking about AlliedmaterialsExistencelocationcopies and AmExLocCop.

- Phil

/me just discovered that this forum recognizes "/me"
Title: Re: custom metadata tags and aliases
Post by: hvdwolf on September 14, 2020, 12:03:29 PM
Quote from: StarGeek on September 14, 2020, 11:10:49 AM
Quote from: hvdwolf on September 14, 2020, 04:11:18 AMOnly the "Reference" shortcut works. Not the other ones.
What am I doing wrong?

Probably the fact that there already exists Title and Date tags.
C:\>exiftool -g1 -a -s -title -date y:\!temp\Test4.jpg
---- XMP-dc ----
Date                            : 2020:09:14 08:08:30-07:00
Title                           : test

That was also my first thought, but also the Reference tag exists. In DICOM. I already checked all available tags.
There are multiple tags in multiple categories that are exactly the same. A good example is all the makernotes tags in the several Canon/Nikon/Panasonic/etcetera categories.

The difference can only be that if it occurs in XMP (as XMP-dc) it can't occur in another XMP-xyz category. (I assume)