I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-05-13 12:15:19-07 by pixelpicker
Creating custom tags for keywords caption and headline...
Hello to all & special to Phil,

I want to create a second set for keywords caption and headline in the IPTC group to store corresponding information from another language.
What I tried up to now is to define a new set of tags in the .config file like this:

%Image::ExifTool::UserDefined = ( # IPTC tags are added to a specific record type (ie. application record): 'Image::ExifTool::IPTC::ApplicationRecord' => { 301 => { Name => 'EKeywords', Format => 'string[0,64]', }, 302 => { Name => 'ECaption-Abstract', Format => 'string[0,4000]', }, 303 => { Name => 'EHeadline', Format => 'string[0,600]', }, }, );

In a first test I tried to copy the corresponding data outof the common iptc group into this new iptc tags with:

exiftool "-IPTC:ekeywords<keywords" "-IPTC:ecaption-abstract<caption-abstract" "-IPTC:eheadline<hea +dline" DIR

Exiftool seems to do its job, but when I look into the metadata with: -a -G1 -s and with: -U I cant't find the new tags. I know that wit the keywords is a problem cause its a list tag but with both others it should have worked.
Could anybody give me a hint?

Many greetings from
pixelpicker
Direct Responses: 10688 | Write a response
Posted on 2009-05-13 12:32:03-07 by exiftool in response to 10687
Re: Creating custom tags for keywords caption and headline...
Oops. Mea culpa.

The IPTC tag ID numbers are one byte, so they are limited to the range 0-255. I will change the example to use 240 instead of 300 and make a note to this effect.

- Phil
Direct Responses: 10691 | Write a response
Posted on 2009-05-13 16:57:12-07 by pixelpicker in response to 10688
Re: Creating custom tags for keywords caption and headline...
Shame on you :)))

Works perfect now with the one byte numers!

THANK YOU a lot!

Best greetings from
pixelpicker
Direct Responses: 10698 | Write a response
Posted on 2009-05-13 20:06:21-07 by pixelpicker in response to 10691
Re: Creating custom tags for keywords caption and headline...
Sorry - works, but not properly:

in my config-file are three different scripts now: my tagsA for search and replace in keywords, caption and headline - my tagsB for search and delete words before and after a separator | - and last my tagsC for creating new iptc tags for a secons language. All new tags have different names.

It comes out now, that the config file doesn`t work, when all new tags are defined in it, there seems to be a conflict: exiftool doesn't creates the new tags and says: 1 directories scannes 0 image files updated. If I delete two of the own tag definitions, the third alone in the config always runs properly.

Do I have to write three different config-files and change them according to what should be done?

Greetings from
pixelpicker
Direct Responses: 10699 | Write a response
Posted on 2009-05-13 21:20:24-07 by pixelpicker in response to 10698
Re: Creating custom tags for keywords caption and headline...

After a closer look:
the problem occures only with the definition for the custom iptc tags!
If I delete the iptc tag definitions from the config file, all other custom tags (both are composite tags) work without problem.

Greetings from
pixelpicker
Direct Responses: 10701 | Write a response
Posted on 2009-05-14 00:18:38-07 by exiftool in response to 10699
Re: Creating custom tags for keywords caption and headline...
I suspect there is something wrong with your config file. Did you put all of the tag definitions within a single Image::ExifTool::UserDefined hash?

Post the config file here (inside a <code> ... </code> block) and maybe I can figure out what is going on.

- Phil
Direct Responses: 10702 | Write a response
Posted on 2009-05-14 00:48:50-07 by pixelpicker in response to 10701
Re: Creating custom tags for keywords caption and headline...
This is the complete config file:
#------------------------------------------------------------------------------ # 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. # # 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 new tag. # # To activate this file, rename it to ".ExifTool_config" and # place it in your home directory or the exiftool application # directory. 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) # # This sample file defines the following 13 new tags as well as a # number of Shortcut and Composite tags: # # 1. EXIF:NewEXIFTag # 2. IPTC:NewIPTCTag # 3. XMP-xmp:NewXMPxmpTag # 4. XMP-xxx:NewXMPxxxTag1 # 5. XMP-xxx:NewXMPxxxTag2 # 6. XMP-xxx:NewXMPxxxTag3 # 7. XMP-xxx:NewXMPxxxStructX # 8. XMP-xxx:NewXMPxxxStructY # 9. PNG:NewPngTag1 # 10. PNG:NewPngTag2 # 11. PNG:NewPngTag3 # 12. MIE-Meta:NewMieTag1 # 13. MIE-Test:NewMieTag2 # # For detailed information on the definition of tag tables and # tag information hashes, see lib/Image/ExifTool/README. #------------------------------------------------------------------------------ # Shortcut tags are used when extracting information to simplify # commonly used commands. They can be used to represent groups # of tags, or to provide an alias for a tag name. %Image::ExifTool::Shortcuts::UserDefined = ( MyShortcut => ['exif:createdate','exposuretime','aperture'], MyAlias => 'FocalLengthIn35mmFormat', ); # NOTE: All tag names used in the following tables are case sensitive. # The %Image::ExifTool::UserDefined hash defines new tags to be added # to existing tables. %Image::ExifTool::UserDefined = ( # All EXIF tags are added to the Main table, and WriteGroup is used to # specify where the tag is written (default is ExifIFD if not specified): 'Image::ExifTool::Exif::Main' => { 0xd000 => { Name => 'NewEXIFTag', Writable => 'int16u', WriteGroup => 'IFD0', }, }, # IPTC tags are added to a specific record type (ie. application record): 'Image::ExifTool::IPTC::ApplicationRecord' => { 240 => { Name => 'NewIPTCTag', Format => 'string[0,16]', }, }, # XMP tags may be added to existing namespaces: 'Image::ExifTool::XMP::xmp' => { NewXMPxmpTag => { Groups => { 2 => 'Author' } }, }, # new XMP namespaces (ie. xxx) must be added to the Main XMP table: 'Image::ExifTool::XMP::Main' => { xxx => { SubDirectory => { TagTable => 'Image::ExifTool::UserDefined::xxx', # (see the definition of this table below) }, }, }, # new PNG tags are added to the PNG::TextualData table: 'Image::ExifTool::PNG::TextualData' => { NewPngTag1 => { }, NewPngTag2 => { }, NewPngTag3 => { }, }, # add a new MIE tag (MieTag1) and group (MIE-Test) to MIE-Meta # (Note: MIE group names must NOT end with a number) 'Image::ExifTool::MIE::Meta' => { NewMieTag1 => { Writable => 'rational64u', Units => [ qw(cm in) ], }, Test => { SubDirectory => { TagTable => 'Image::ExifTool::UserDefined::MIETest', DirName => 'MIE-Test', }, }, }, # 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. (See the Composite table in # Image::ExifTool::Exif for more examples.) BaseName => { Require => { 0 => 'FileName', }, # remove the extension from FileName ValueConv => 'my $name=$val[0]; $name=~s/\..*?$//; $name', }, # the following examples demonstrate simplifications which may be # used if only one tag is Require'd or Desire'd: # 1) the Require/Desire lookup may be replaced with a simple tag name # 2) "$val" may be used to represent "$val[0]" in the expression Extension => { Require => 'FileName', ValueConv => '$val=~/\.([^.]*)$/; $1', }, # override CircleOfConfusion tag to use D/1750 instead of D/1440 CircleOfConfusion => { Require => 'ScaleFactor35efl', ValueConv => 'sqrt(24*24+36*36) / ($val * 1750)', PrintConv => 'sprintf("%.3f mm",$val)', }, }, ); # This is a basic example of the definition for a new XMP namespace. # This table is referenced through a SubDirectory tag definition # in the %Image::ExifTool::UserDefined definition above. # The namespace prefix for these tags is 'xxx', which corresponds to # an ExifTool family 1 group name of 'XMP-xxx'. %Image::ExifTool::UserDefined::xxx = ( GROUPS => { 0 => 'XMP', 1 => 'XMP-xxx', 2 => 'Image' }, NAMESPACE => { 'xxx' => 'http://ns.myname.com/xxx/1.0/' }, WRITABLE => 'string', # replace "NewXMPxxxTag1" with your own tag name (ie. "MyTag") NewXMPxxxTag1 => { }, NewXMPxxxTag2 => { Groups => { 2 => 'Author' } }, NewXMPxxxTag3 => { List => 'Bag' }, # XMP structures are defined as SubDirectory's NewXMPxxxStruct => { SubDirectory => { }, Struct => 'MyStruct', # arbitrary name identifies entry in xmpStruct List => 'Seq', # structures may also be elements of a list }, # structure elements must be defined as separate tags. The tag ID's # are the concatination of the structure tag ID with the ID of each # structure element in turn. The list flag should be set if the # parent structure is contained in a list. NewXMPxxxStructX => { List => 1 }, NewXMPxxxStructY => { List => 1 }, ); # User-defined XMP structures are added to the xmpStruct lookup %Image::ExifTool::UserDefined::xmpStruct = ( # A structure with 2 elements: X and Y MyStruct => { NAMESPACE => { 'test' => 'http://x.y.z/test/' }, # TYPE is optional -- it adds an rdf:type element to the structure TYPE => 'http://x.y.z/test/xystruct', X => { }, Y => { }, }, ); # Adding a new MIE group requires a few extra definitions use Image::ExifTool::MIE; %Image::ExifTool::UserDefined::MIETest = ( %Image::ExifTool::MIE::tableDefaults, # default MIE table entries GROUPS => { 0 => 'MIE', 1 => 'MIE-Test', 2 => 'Document' }, WRITE_GROUP => 'MIE-Test', NewMieTag2 => { }, # new user-defined tag in MIE-Test group ); # A special 'Lenses' list can be defined to give priority to specific lenses # in the logic to determine a lens model for the Composite:LensID tag @Image::ExifTool::UserDefined::Lenses = ( 'Sigma AF 10-20mm F4-5.6 EX DC', 'Tamron 35-90mm F4 AF', ); #---- My own TagsA -------------------------------------------------------------------------- %Image::ExifTool::UserDefined = ( 'Image::ExifTool::Composite' => { MyKeywords => { Require => 'Keywords', ValueConv => q{ my @list = ref $val ? @$val : ($val); my $changed; s/'/ /g and $changed = 1 foreach @list; return $changed ? \@list : undef; }, }, MyCaption => { Require => 'Caption-Abstract', ValueConv => q{ $val=~s/'/ /g ? $val : undef }, }, MyHeadline => { Require => 'Headline', ValueConv => q{ $val=~s/'/ /g ? $val : undef }, }, }, ); #---- My own TagsB ------------------------------------------------------------------------- %Image::ExifTool::UserDefined = ( 'Image::ExifTool::Composite' => { KeywordsDeutsch => { Require => 'IPTC:Keywords', ValueConv => q{ my @list = ref $val ? @$val : ($val); my $changed; s/([^\|]*)\| .*/\1/ and $changed = 1 foreach @list; return $changed ? \@list : undef; }, }, KeywordsEnglish => { Require => 'IPTC:Keywords', ValueConv => q{ my @vals; foreach (ref $val eq 'ARRAY' ? @$val : $val) { push @vals, $2 if /(^|\|)\s*\s+(.*?)\s*(\||$)/; } return @vals ? \@vals : undef; }, }, CaptionDeutsch => { Require => 'IPTC:Caption-Abstract', ValueConv => '$val =~ /^(.*?)\s*\|/s ? $1 : undef', }, CaptionEnglish => { Require => 'IPTC:Caption-Abstract', ValueConv => '$val =~ /\|\s*(.*?)$/s ? $1 : undef', }, HeadlineDeutsch => { Require => 'IPTC:Headline', ValueConv => '$val =~ /^(.*?)\s*\|/s ? $1 : undef', }, HeadlineEnglish => { Require => 'IPTC:Headline', ValueConv => '$val =~ /\|\s*(.*?)$/s ? $1 : undef', }, }, ); #---- My own TagsC ------------------------------------------------------------------------- %Image::ExifTool::UserDefined = ( 'Image::ExifTool::IPTC::ApplicationRecord' => { 235 => { Name => 'KeywordsENGL', Format => 'string[0,64]', }, 236 => { Name => 'CaptionENGL', Format => 'string[0,2000]', }, 237 => { Name => 'HeadlineENGL', Format => 'string[0,600]', }, }, ); #------------------------------------------------------------------------------ 1; #end

Greetings
Direct Responses: 10709 | Write a response
Posted on 2009-05-14 11:02:06-07 by exiftool in response to 10702
Re: Creating custom tags for keywords caption and headline...
Yes. The problem is as I suspected. You must put all definitions within a single %Image::ExifTool::UserDefined hash.

- Phil
Direct Responses: 10711 | Write a response
Posted on 2009-05-14 13:38:27-07 by pixelpicker in response to 10709
Re: Creating custom tags for keywords caption and headline...

!! Thank you Phil !! :)

So this means I have just to rearrange the config file and put all definitions under the:
%Image::ExifTool::UserDefined = (
if I understand you correct.

I searched for the "lib/Image/ExifTool/README" that is mentioned in the config file but cant't find it. Since the use of the config file is very helpful for many cases, I'd like to know more. Could you tell me where to read or download it?

Best Greetings
Bette
Direct Responses: 10712 | Write a response
Posted on 2009-05-14 14:12:28-07 by exiftool in response to 10711
Re: Creating custom tags for keywords caption and headline...
Hi Bette,

The lib/Image/ExifTool/README file and sample ExifTool_config file are both found in the full Perl distribution.

As well, you can see additional examples of tag definitions in the ExifTool modules themselves.

- Phil
Direct Responses: 10713 | Write a response
Posted on 2009-05-14 14:30:47-07 by pixelpicker in response to 10712
Re: Creating custom tags for keywords caption and headline...

Thank you again :)

I will download the full Perl distribution again to see all examples - since some time now I use your windows standalone cause its so nicly slim and uncomplicated.

Have a good day!

Greetings
Bette
Direct Responses: Write a response