ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Kevin P. Neal on October 18, 2015, 06:52:40 PM

Title: Restricting XMP field to specific values?
Post by: Kevin P. Neal on October 18, 2015, 06:52:40 PM
I'm trying to get exiftool writing the XMP for AnalogExif, and one of the fields is defined to have only specific values. I tried using PrintConv but it didn't do any restricting:

%Image::ExifTool::UserDefined::AnalogExif = (
# ...

    FilmType => {
        PrintConv => {
            '135' => 135,
            '120' => 120,
            'Disc' => Disc
        }
    },

What's the trick to having the command line tool reject invalid values for this field?

Thanks for any help!
Title: Re: Restricting XMP field to specific values?
Post by: Phil Harvey on October 19, 2015, 07:24:57 AM
But you can write this tag?  If so, your user-defined tag must be working.  This is the way to do it, although "Disc" must be quoted on the right side.  It is the quoting on the left side that is optional:

            Disc => 'Disc',

But I don't think this should stop the restriction from happening.  Make sure you aren't using the -n option to bypass the PrintConv.

- Phil
Title: Re: Restricting XMP field to specific values?
Post by: Kevin P. Neal on January 27, 2016, 05:12:45 PM
Thanks for the help. I went ahead and quoted both sides because some of these film types are defined to have Unicode characters in them. *sigh*

Anyway, here's the whole thing but without descriptions. I'm not sure if copyright allows for copying of field descriptions verbatim so I just left them out. If anyone can use this then you are welcome to it:


#------------------------------------------------------------------------------
# File:         .Exiftool.config
#
# Description:  Define tags for AnalogExif compatibility
#
# Notes:
#------------------------------------------------------------------------------

# The %Image::ExifTool::UserDefined hash defines new tags to be added
# to existing tables.
%Image::ExifTool::UserDefined = (
    # new XMP namespaces (eg. xxx) must be added to the Main XMP table:
    'Image::ExifTool::XMP::Main' => {
        # namespace definition for examples 8 to 11
        AnalogExif => { # <-- must be the same as the NAMESPACE prefix
            SubDirectory => {
                TagTable => 'Image::ExifTool::UserDefined::AnalogExif',
                # (see the definition of this table below)
            },
        },
        # add more user-defined XMP namespaces here...
    },
);

%Image::ExifTool::UserDefined::AnalogExif = (
    GROUPS => { 0 => 'XMP', 1 => 'XMP-AnalogExif', 2 => 'Image' },
    NAMESPACE => { 'AnalogExif' => 'http://analogexif.sourceforge.net/ns/' },
    WRITABLE => 'string',

    ExposureNumber => { Writable => 'integer' },
    LensSerialNumber => { Avoid => 1 },
    RollId => { },
    FilmMaker => { },
    Film => { },
    FilmAlias => { },
    FilmGrain => { Writable => 'integer' },
    FilmType => {
        PrintConv => {
            '135' => '135',
            '120' => '120',
            '220' => '220',
            'APS' => 'APS',
            '4×5' => '4×5',
            '8×10' => '8×10',
            'Type 600' => 'Type 600',
            '127' => '127',
            'Disc' => 'Disc',
            'Paper' => 'Paper',
            '126' => '126',
            '101' => '101',
            '102' => '102',
            '103' => '103',
            '104' => '104',
            '105' => '105',
            '106' => '106',
            '107' => '107',
            '108' => '108',
            '109' => '109',
            '110' => '110',
            '111' => '111',
            '112' => '112',
            '113' => '113',
            '114' => '114',
            '115' => '115',
            '116' => '116',
            '117' => '117',
            '118' => '118',
            '119' => '119',
            '121' => '121',
            '122' => '122',
            '123' => '123',
            '124' => '124',
            '125' => '125',
            '128' => '128',
            '129' => '129',
            '235' => '235',
            '335' => '335',
            '435' => '435',
            '518' => '518',
            '520' => '520',
            '522' => '522',
            '523' => '523',
            '616' => '616',
            '617' => '617',
            '620' => '620',
            '645' => '645',
            '828' => '828',
            '35' => '35',
            'Minox' => 'Minox',
            'Karat' => 'Karat',
            'Rapid' => 'Rapid',
            'SL' => 'SL',
            'K 16' => 'K 16',
            '1⅝×2⅛' => '1⅝×2⅛',
            '2×2½' => '2×2½',
            '2×3' => '2×3',
            '2½×3½' => '2½×3½',
            '3×4' => '3×4',
            '3⅛×4⅛' => '3⅛×4⅛',
            '3¼×4¼' => '3¼×4¼',
            '3¼×5½' => '3¼×5½',
            '4¾×6½' => '4¾×6½',
            '4½×5½' => '4½×5½',
            '4×10' => '4×10',
            '5×7' => '5×7',
            '7×17' => '7×17',
            '8×20' => '8×20',
            '8½×6½' => '8½×6½',
            '11×14' => '11×14',
            '12×20' => '12×20',
            '14×17' => '14×17',
            '16×20' => '16×20',
            '20×24' => '20×24',
            '6.5×9' => '6.5×9',
            '9×12' => '9×12',
            '10×15' => '10×15',
            '13×18' => '13×18',
            '18×24' => '18×24',
            '24×30' => '24×30',
            'SX-70' => 'SX-70',
            'Type 37' => 'Type 37',
            'Type 47' => 'Type 47',
            'Type 88' => 'Type 88',
            'Type 100' => 'Type 100'
        }
    },
    Developer => { },
    DevelopProcess => { },
    DeveloperMaker => { },
    DeveloperDilution => { },
    DevelopTime => { },
    Lab => { },
    LabAddress => { },
    Filter => { },
    ScannerMaker => { },
    Scanner => { },
    ScannerSoftware => { },
);

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