ExifTool Forum

ExifTool => Newbies => Topic started by: zzyzx on November 12, 2013, 04:28:06 AM

Title: IPTC Custom fields
Post by: zzyzx on November 12, 2013, 04:28:06 AM
Hi,
I would like to read/write the IPTC Custom fields (ID 200-219). Unfortunately they aren't listed in http://www.exiftool.org/TagNames/IPTC.html. Is there any way to reach them? Maybe "-IPTC:201"?

Regards
Title: Re: IPTC Custom fields
Post by: Phil Harvey on November 12, 2013, 07:31:26 AM
Yes.  To do this you must create user-defined tags.  See the NewIPTCTag in the sample config file (https://exiftool.org/config.html) for an example of how to do this.

- Phil
Title: Re: IPTC Custom fields
Post by: zzyzx on December 08, 2013, 11:47:40 AM
Hi Phil,
thanks for your reply.
I tried to include the config file. But it doesn't work.

.ExifTool_config - File:
Code: [Select]
#------------------------------------------------------------------------------
# .ExifTool_config
#------------------------------------------------------------------------------

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        200 => { Name => 'CustomField1', Format => 'string[0,256]' },
        201 => { Name => 'CustomField2', Format => 'string[0,256]' },
        202 => { Name => 'CustomField3', Format => 'string[0,256]' },
        203 => { Name => 'CustomField4', Format => 'string[0,256]' },
        204 => { Name => 'CustomField5', Format => 'string[0,256]' },
        205 => { Name => 'CustomField6', Format => 'string[0,256]' },
        206 => { Name => 'CustomField7', Format => 'string[0,256]' },
        207 => { Name => 'CustomField8', Format => 'string[0,256]' },
        208 => { Name => 'CustomField9', Format => 'string[0,256]' },
        209 => { Name => 'CustomField10', Format => 'string[0,256]' },
        210 => { Name => 'CustomField11', Format => 'string[0,256]' },
        211 => { Name => 'CustomField12', Format => 'string[0,256]' },
        212 => { Name => 'CustomField13', Format => 'string[0,256]' },
        213 => { Name => 'CustomField14', Format => 'string[0,256]' },
        214 => { Name => 'CustomField15', Format => 'string[0,256]' },
        215 => { Name => 'CustomField16', Format => 'string[0,256]' },
        216 => { Name => 'CustomField17', Format => 'string[0,256]' },
        217 => { Name => 'CustomField18', Format => 'string[0,256]' },
        218 => { Name => 'CustomField19', Format => 'string[0,256]' },
        219 => { Name => 'CustomField20', Format => 'string[0,256]' },
    },
);

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

PHP-File:
Code: [Select]
$root = $_SERVER['DOCUMENT_ROOT'].".ExifTool_config";
exec("exiftool -config ".$root." -X -L -b -IPTC:CustomField1 -IPTC:City -IPTC:DateCreated ".$_SERVER['DOCUMENT_ROOT']."img/".$file, $output);

Response:
Code: [Select]
<?xml version='1.0' encoding='windows-1252'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about='/www/htdocs/w0007/.ExifTool_config'
  xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 7.89'>
</rdf:Description>

<rdf:Description rdf:about='/www/htdocs/w0007/img/test.JPG'
  xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 7.89'
  xmlns:IPTC='http://ns.exiftool.ca/IPTC/IPTC/1.0/'>
 <IPTC:City>LA</IPTC:City>
 <IPTC:DateCreated>2013:12:08</IPTC:DateCreated>
</rdf:Description>
</rdf:RDF>

best regards
Title: Re: IPTC Custom fields
Post by: Phil Harvey on December 08, 2013, 02:03:23 PM
Works for me:

Code: [Select]
> exiftool -ver
9.43

> exiftool a.jpg -all=
    1 image files updated

> exiftool -config tmp/.ExifTool_config a.jpg -customfield1=test1 -city=test2
    1 image files updated

> exiftool -config tmp/.ExifTool_config a.jpg -customfield1 -city -X -L -b
<?xml version='1.0' encoding='windows-1252'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about='a.jpg'
  xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 9.43'
  xmlns:IPTC='http://ns.exiftool.ca/IPTC/IPTC/1.0/'>
 <IPTC:CustomField1>test1</IPTC:CustomField1>
 <IPTC:City>test2</IPTC:City>
</rdf:Description>
</rdf:RDF>

> cat tmp/.ExifTool_config
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        200 => { Name => 'CustomField1', Format => 'string[0,256]' },
        201 => { Name => 'CustomField2', Format => 'string[0,256]' },
        202 => { Name => 'CustomField3', Format => 'string[0,256]' },
        203 => { Name => 'CustomField4', Format => 'string[0,256]' },
        204 => { Name => 'CustomField5', Format => 'string[0,256]' },
        205 => { Name => 'CustomField6', Format => 'string[0,256]' },
        206 => { Name => 'CustomField7', Format => 'string[0,256]' },
        207 => { Name => 'CustomField8', Format => 'string[0,256]' },
        208 => { Name => 'CustomField9', Format => 'string[0,256]' },
        209 => { Name => 'CustomField10', Format => 'string[0,256]' },
        210 => { Name => 'CustomField11', Format => 'string[0,256]' },
        211 => { Name => 'CustomField12', Format => 'string[0,256]' },
        212 => { Name => 'CustomField13', Format => 'string[0,256]' },
        213 => { Name => 'CustomField14', Format => 'string[0,256]' },
        214 => { Name => 'CustomField15', Format => 'string[0,256]' },
        215 => { Name => 'CustomField16', Format => 'string[0,256]' },
        216 => { Name => 'CustomField17', Format => 'string[0,256]' },
        217 => { Name => 'CustomField18', Format => 'string[0,256]' },
        218 => { Name => 'CustomField19', Format => 'string[0,256]' },
        219 => { Name => 'CustomField20', Format => 'string[0,256]' },
    },
);

What is the "." doing before "$root" in the config file path?  Are you sure the path is correct?

- Phil
Title: Re: IPTC Custom fields
Post by: zzyzx on December 10, 2013, 06:08:06 AM
Do you mean the dot in front of ".ExifTool_config"?
If I rename the path, it also doesn't work.
Code: [Select]
exec("exiftool -config /www/htdocs/w0007/myconfig.cfg -X -L -b -IPTC:CustomField1 -IPTC:City -IPTC:DateCreated ".$_SERVER['DOCUMENT_ROOT']."img/".$file, $output);
Title: Re: IPTC Custom fields
Post by: Phil Harvey on December 10, 2013, 07:08:55 AM
I meant the dot before (and after) "$root", but I see now those are string concatenation operators.

Does it work for you on the command line?

- Phil
Title: Re: IPTC Custom fields
Post by: zzyzx on December 10, 2013, 07:19:52 AM
Unfortunately not. Didn't load the config file. No matter which file name.
Title: Re: IPTC Custom fields
Post by: Phil Harvey on December 10, 2013, 07:36:56 AM
Oh, wow.  I just noticed from your XML output that you are using ExifTool 7.89.  That version is more than 4 years old!  Try updating to a more recent version.  The -config option was added in version 7.98 (also more than 4 years ago).  There is a reason that the -ver command was first in my console log.

- Phil
Title: Re: IPTC Custom fields
Post by: zzyzx on December 10, 2013, 07:49:15 AM
Uh, 4 years.
Okay, I try to update the tool. Then it should work.  :)

Thanks for your help.