Author Topic: IPTC Custom fields  (Read 4016 times)

zzyzx

  • Newbie
  • *
  • Posts: 5
IPTC Custom fields
« 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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16899
    • ExifTool Home Page
Re: IPTC Custom fields
« Reply #1 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 for an example of how to do this.

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

zzyzx

  • Newbie
  • *
  • Posts: 5
Re: IPTC Custom fields
« Reply #2 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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16899
    • ExifTool Home Page
Re: IPTC Custom fields
« Reply #3 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
...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 ($).

zzyzx

  • Newbie
  • *
  • Posts: 5
Re: IPTC Custom fields
« Reply #4 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);

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16899
    • ExifTool Home Page
Re: IPTC Custom fields
« Reply #5 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
...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 ($).

zzyzx

  • Newbie
  • *
  • Posts: 5
Re: IPTC Custom fields
« Reply #6 on: December 10, 2013, 07:19:52 AM »
Unfortunately not. Didn't load the config file. No matter which file name.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16899
    • ExifTool Home Page
Re: IPTC Custom fields
« Reply #7 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
...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 ($).

zzyzx

  • Newbie
  • *
  • Posts: 5
Re: IPTC Custom fields
« Reply #8 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.