Author Topic: Best way to create a tag alias for reading *and* writing  (Read 2686 times)

Tr

  • Jr. Member
  • **
  • Posts: 29
Best way to create a tag alias for reading *and* writing
« on: February 25, 2014, 05:28:14 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: Best way to create a tag alias for reading *and* writing
« Reply #1 on: February 25, 2014, 07:26:07 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

  • Jr. Member
  • **
  • Posts: 29
Re: Best way to create a tag alias for reading *and* writing
« Reply #2 on: February 26, 2014, 10:18:47 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: Best way to create a tag alias for reading *and* writing
« Reply #3 on: February 26, 2014, 10:50:30 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

  • Jr. Member
  • **
  • Posts: 29
Re: Best way to create a tag alias for reading *and* writing
« Reply #4 on: February 26, 2014, 01:03:27 PM »

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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: Best way to create a tag alias for reading *and* writing
« Reply #5 on: February 26, 2014, 01:15:04 PM »
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:

Code: [Select]
%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.
« Last Edit: February 26, 2014, 01:36:34 PM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

  • Jr. Member
  • **
  • Posts: 29
Re: Best way to create a tag alias for reading *and* writing
« Reply #6 on: February 26, 2014, 01:29:47 PM »
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