Main Menu

IPTC Custom fields

Started by zzyzx, November 12, 2013, 04:28:06 AM

Previous topic - Next topic

zzyzx

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

zzyzx

Hi Phil,
thanks for your reply.
I tried to include the config file. But it doesn't work.

.ExifTool_config - File:
#------------------------------------------------------------------------------
# .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:

$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:

<?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

Works for me:

> 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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

zzyzx

Do you mean the dot in front of ".ExifTool_config"?
If I rename the path, it also doesn't work.
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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

zzyzx

Unfortunately not. Didn't load the config file. No matter which file name.

Phil Harvey

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

zzyzx

Uh, 4 years.
Okay, I try to update the tool. Then it should work.  :)

Thanks for your help.