ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: sevimo on February 18, 2015, 08:37:51 PM

Title: User-defined namespace tags in composites?
Post by: sevimo on February 18, 2015, 08:37:51 PM
Hi, I am trying to customize image metadata with my own tags (I think I am a victim of ExifTool being too flexible ;) ), and there is one thing doesn't seem to work for me. I defined my own XMP sub-namespace for my tags, and it seems to work just fine, as in I can read/write these tags without issues. Here is an example of namespace definition:


%Image::ExifTool::UserDefined::xmpVM = (
    GROUPS => { 0 => 'XMP', 1 => 'XMP-xmpVM', 2 => 'Image' },
    NAMESPACE => { 'xmpVM' => 'http://ns.xxx.net/xmpVM/1.0/' },
    WRITABLE => 'string',
    vmIdNumber => { Writable => 'string' },
    vmOriginalRawFilename => { Writable => 'string' },
    vmTimeZoneOffset => { Writable => 'string' },
);


Now, vmOriginalRawFilename is populated only for sidecar XMP files (contains file name of the corresponding raw); this tag is not present in JPG/CR2/etc files. Now I wanted to define a composite tag that would return vmOriginalRawFilename if it is present, and FileName otherwise. Here is how I've done it:


    'Image::ExifTool::Composite' => {
        vmOriginalFileName => {
            Desire => {
            0 => 'FileName',
                    1 => 'XMP-xmpVM:vmOriginalRawFilename',
            },
            ValueConv => '(defined $val[1]) ? $val[1] : $val[0]',
        },
    }


This composite always returns FileName, i.e. the second (user-defined) tag is never defined, even though it certainly is in my XMP file. If I replace the second tag with something standard (e.g. XMP-xmp:CreateDate), the composite works as expected. But for user-defined namespace tag I was unable to get it to work, no matter what kind of qualifiers I put in front of the tag name. Is it supposed to work in the first place, and if yes, what am I doing wrong?

Thanks!
Title: Re: User-defined namespace tags in composites?
Post by: Phil Harvey on February 19, 2015, 07:11:12 AM
Your problem is that the Require/Desire tag names are case sensitive.  You muse use "XMP-xmpVM:VmOriginalRawFilename".

If you will notice, ExifTool automaticallly capitalized the first letter in your tag name (use -s when extracting to see the exact tag name).

- Phil
Title: Re: User-defined namespace tags in composites?
Post by: sevimo on February 19, 2015, 08:11:03 AM
Awesome, that worked. I thought I tried all the permutations, but apparently not ;) I never thought that capitalization in -s mattered as in the config I spelled it differently, and from the command line capitalization doesn't seem to matter at all.

Thanks!

Is there any particular reason for having it case-sensitive in this spot, while not in others?
Title: Re: User-defined namespace tags in composites?
Post by: Phil Harvey on February 19, 2015, 08:51:36 AM
I would prefer case insensitive everywhere, but unfortunately in some places (like in the Require/Desire tags) coding case insensitivity would be very inefficient.  Also, case is sensitive everywhere else in the config file, so the rules are simple:  The command line is not case sensitive, but the config file is.  This is mentioned in the sample config file, but I can see how it would be easy to overlook:

# NOTE: All tag names used in the following tables are case sensitive.

I think the biggest source of confusion here may be that ExifTool automatically generates a tag Name from the capitalized tag ID for XMP tags if not otherwise specified.  The algorithm for generating the tag Name is not well documented.

- Phil

Edit:  I have just added a note about this to FAQ 11 (https://exiftool.org/faq.html#Q11).
Title: Re: User-defined namespace tags in composites?
Post by: sevimo on February 19, 2015, 10:05:13 AM
You're right about the source of confusion - I did see the comment about case-sensitivity of this section, and made sure that I double checked (and finally just copy-pasted) tags as I spelled them in the config. But case-sensitivity was for tag names that were implicitly generated, not ids that I defined. To add to the confusion, I could see my tags in XMP file spelled exactly the way I specified it in the config (i.e. no capitalization). I always thought that capitalization was only for display purposes, so ignored it.

I'll probably just specify tag names explicitly:


vmOriginalRawFilename => { Writable => 'string', Name => 'vmOriginalRawFilename' },


Looks a bit redundant, but this way I won't need to worry about capitalization (at least for my own custom tags) - correct? I know that it seems to work, but are there any issues with doing it this way?
Title: Re: User-defined namespace tags in composites?
Post by: Phil Harvey on February 19, 2015, 12:14:39 PM
You can name them however you want.  This will work.  It is only an ExifTool convention to capitalize the first letter.

- Phil