IPTC parsing with PHP

Patrick O\’Lone [1] proposed a package to PEAR that handles IPTC parsing and abstracts the iptcparse() and iptcembed() functions.

The class abstracts the retrieving and setting of IPTC field tags. It
supports multi-tagged values, such as those found in the \’keywords\’
section of an IPTC header. The class basically works like this:

<?php

$oIPTC =& new Image_IPTC(\”test.jpg\”);

echo \”The original caption was: \”;
echo $oIPTC->getTag(IMAGE_IPTC_CAPTION);
echo \”<br />\”;

$oIPTC->setTag(IMAGE_IPTC_CAPTION, \”An example caption.\”);
$oIPTC->setTag(IMAGE_IPTC_KEYWORDS, \”Keyword 1\”, 0);
$oIPTC->setTag(IMAGE_IPTC_KEYWORDS, \”Keyword 2\”, 1);
$oIPTC->save(\”output.jpg\”);

print_r($oIPTC->getAllTags());
?>

This leads me back to the \”old\” idea, embedding exif-rdf\’d data into the images itself [2] using PHP functions.

[1] http://www.townnews.com/contrib/IPTC.html
[2] http://www.w3.org/TR/photo-rdf/

Leave a Reply