News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Best way to create a tag alias for reading *and* writing

Started by Tr, February 25, 2014, 05:28:14 PM

Previous topic - Next topic

Tr

Tried this approach:

%Image::ExifTool::UserDefined::Shortcuts = (
    IPTC_Credit => 'IPTC:Credit',
    XMP_Credit => 'XMP:Credit',
);

Got message:
exiftool -IPTC_Credit="This is the IPTC_Credit" hs-2013-35-a-full_tif.tif
Warning: Tag 'IPTC_Credit' does not exist
Nothing to do.

thanks.

Phil Harvey

Quite right.  ExifTool can not currently write a shortcut tag where the group is specified for the target tag.  This is an oversight.  I will see about adding this ability in the next release (ExifTool 9.54).

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

Tr

Thanks Phil.

In the meantime, is there anyway to extract *both* IPTC:Credit and XMP:Credit into a csv file and keep them separated without the -G0 option?  As of now, they are both extracted into the same column header: 'Credit'.

We don't want to deal with the group names for ~60 tags we are dealing with.  Hence, no -G option.  But in this particular case we do want to keep the 2 Credit(s) separate to validate and modify each independently.

Would a Composite Tag help in this case?  Is there an example of how to write to a Composite Tag?

Thanks so much.

Phil Harvey

Ah.  I was wondering why you were doing this.

Your shortcut idea wouldn't have worked anyway, because actual tag names would still be used for the column headings.

From the documentation for the -csv option:

If the -a option is used to allow duplicate tag names, the duplicate tags are only included in the CSV output if the column headings are unique.

So the only way to do what you want without adding a group name is to rename the tag by overriding the definition (not recommended) or create Composite tag to duplicate the tag with a different name (as you mentioned).  The sample config file has a number of examples.

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

Tr


Below is my Composite Attempt.  I am getting the following message:
exiftool -IPTC_Credit="This is IPTC_Credit." hs-2013-35-a-full_tif.tif
    0 image files updated
    1 image files unchanged

'Image::ExifTool::Composite' => {
      IPTC_Credit => {
            Require => { 0 => 'IPTC:Credit' },
            Writable => 'string',
            PrintConv => '$val',
            PrintConvInv => '$val'
        }, 
        XMP_Credit => {
            Require => { 0 => 'XMP:Credit' },
            Writable => 'string',
            PrintConv => '$val',
            PrintConvInv => '$val'
        }, 
}

Thanks for any assistance.

Phil Harvey

#5
Right.  You want to write these tags too.  Creating a user-defined writable Composite tag is a bit tricky.  Sorry, I should have realized this and provided an example:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        IPTC_Credit => {
            Require => { 0 => 'IPTC:Credit' },
            Writable => 1,
            WriteAlso => {
                'IPTC:Credit' => '$val',
            },
            ValueConv => '$val',
        }, 
        XMP_Credit => {
            Require => { 0 => 'XMP:Credit' },
            Writable => 1,
            WriteAlso => {
                'XMP:Credit' => '$val',
            },
            ValueConv => '$val',
        }, 
    },
);


The "WriteAlso" definition allows you to write any associated tags that you want (not only limited to the Require'd tags).  "Writable" may be any true value since the write format is not checked by the Composite tag.  I also changed your PrintConv's to ValueConv's, which is how it should be done (otherwise you'll see a nasty "HASH" value if you use the -n option).

- Phil

Edit: I realized the ValueConvInv's weren't necessary, so I removed them from the example.  The necessary inverse conversions are handled by the WriteAlso tags.
...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 ($).

Tr

Awesome!  Thanks Phil.  This was a nasty issue for us reading/writing the 2 Credit(s) in/out of .csv and now it's resolved.   :D :D :D :D