Writability of Custom XMP Fields

Started by blue-j, February 16, 2014, 03:25:47 AM

Previous topic - Next topic

blue-j

The text of the topic is shown below:
I can't for the life of me get these fields to be writable.  I have few hairs left to pull!!  Can anyone help?   Thank you so much in advance, I hope you are well!

- J

Here's my config:


#------------------------------------------------------------------------------
# File:         ExifTool_config  -->  ~/.ExifTool_config
#
# Description:  Sample user configuration file for Image::ExifTool
#
# Notes:        This example file shows how to define your own shortcuts and
#               add new EXIF, IPTC, XMP, PNG, MIE and Composite tags, as well
#               as how to specify preferred lenses for the LensID tag and
#               define default values for ExifTool options.
#
#               Note that unknown tags may be extracted even if they aren't
#               defined, but tags must be defined to be written.  Also note
#               that it is possible to override an existing tag definition
#               with a user-defined tag.
#
#               To activate this file, rename it to ".ExifTool_config" and
#               place it in your home directory or the exiftool application
#               directory.  (On Windows and Mac systems this must be done via
#               the command line since the GUI's don't allow filenames to begin
#               with a dot.  Use the "rename" command in Windows or "mv" on the
#               Mac.)  This causes ExifTool to automatically load the file when
#               run.  Your home directory is determined by the first defined of
#               the following environment variables:
#
#                   1. EXIFTOOL_HOME
#                   2. HOME
#                   3. HOMEDRIVE + HOMEPATH
#                   4. (the current directory)
#
#               Alternatively, the -config option of the exiftool application
#               may be used to load a specific configuration file (note that
#               it must be the first option on the command line):
#
#                   exiftool -config ExifTool_config ...
#
# The %Image::ExifTool::UserDefined hash defines new tags to be added
# to existing tables.

%Image::ExifTool::UserDefined = (
   # new XMP namespaces (ie. xxx) must be added to the Main XMP table:
   'Image::ExifTool::XMP::Main' => {
       levi => { # <-- must be the same as the NAMESPACE prefix
           SubDirectory => {
               TagTable => 'Image::ExifTool::UserDefined::levi',
               # (see the definition of this table below)
           },
       },
       # add more user-defined XMP namespaces here...
   },
);

%Image::ExifTool::UserDefined = (
   # Composite tags are added to the Composite table:
   'Image::ExifTool::Composite' => {
       # Composite tags are unique: The Require/Desire elements list tags
       # that must/may exist, and the keys of these hashes are used as
       # indices in the @val array of the ValueConv expression to derive
       # the composite tag value.  All Require'd tags must exist for the
       # Composite tag to be evaluated.  If no Require'd tags are specified,
       # then at least one of the Desire'd tags must exist.  See the
       # Composite table in Image::ExifTool::Exif for more examples.

       # generate a description for this file type
       FileTypeDescription => {
           Require => 'FileType',
           ValueConv => 'GetFileType($val,1) || $val',
       },
   },
);

# Custom XMP Namespace
%Image::ExifTool::UserDefined::levi = (
   GROUPS        => { 0 => 'XMP', 1 => 'XMP-levi', 2 => 'Image' },
   NAMESPACE     => { 'levi' => 'http://ns.prismpointportal.com/levi/' },
   WRITABLE      => 'string',
   ProductCode => { },
   ProductName => { },
   ColorName => { },
   ImageView => { },
);

#------------------------------------------------------------------------------
1;  #end


Phil Harvey

This is a common mistake.

You have defined %Image::ExifTool::UserDefined twice, so the first definition is ignored.

Your Composite tags definition should go inside the first %Image::ExifTool::UserDefined definition, as is done in the sample config file.

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

blue-j

#2
I just can't seem to find the sweet spot!  Still not writable!

%Image::ExifTool::UserDefined = (
    # new XMP namespaces (ie. xxx) must be added to the Main XMP table:
    'Image::ExifTool::XMP::Main' => {
        levi => { # <-- must be the same as the NAMESPACE prefix
            SubDirectory => {
                TagTable => 'Image::ExifTool::UserDefined::levi',
                # (see the definition of this table below)
            },
        },
    },

    # Composite tags are added to the Composite table:
    'Image::ExifTool::Composite' => {
        # Composite tags are unique: The Require/Desire elements list tags
        # that must/may exist, and the keys of these hashes are used as
        # indices in the @val array of the ValueConv expression to derive
        # the composite tag value.  All Require'd tags must exist for the
        # Composite tag to be evaluated.  If no Require'd tags are specified,
        # then at least one of the Desire'd tags must exist.  See the
        # Composite table in Image::ExifTool::Exif for more examples.
       
        # generate a description for this file type
        FileTypeDescription => {
            Require => 'FileType',
            ValueConv => 'GetFileType($val,1) || $val',
        },
    },
);

# Custom XMP Namespace for Levi Strauss & Co.
%Image::ExifTool::UserDefined::levi = (
    GROUPS        => { 0 => 'XMP', 1 => 'XMP-levi', 2 => 'Image' },
    NAMESPACE     => { 'levi' => 'http://ns.prismpointportal.com/levi/' },
    WRITABLE      => 'string',
    ProductCode => { },
    ProductName => { },
    ColorName => { },
    ImageView => { },
);

#------------------------------------------------------------------------------
1;  #end

SG edit: Fixed error that is mentioned in Phil's post below

Phil Harvey

Close.  I tried it, and I get this error:

> exiftool a.jpg -ImageView=1
syntax error at /Users/phil/.ExifTool_config line 27, near ")"
Missing right curly or square bracket at /Users/phil/.ExifTool_config line 41, at end of line
Warning: Tag 'ImageView' does not exist
Nothing to do.


I am surprised you didn't see this.

The problem is a missing closing brace for 'Image::ExifTool::XMP::Main'.  After I fixed this, it worked for me.

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

blue-j

YES! 

My fault, sorry!  Was testing through our PHP app and not looking at CLI feedback, which was lazy and foolish.  I'll make it up to you!!

Thanks!!!

J