A Blue Star

Extracting the IPTC data from an image in PHP

Posted on March 26th, 2007 by Steven Smethurst

image-missingWhen you add a caption to an image in Google’s Picasa/Picasa2 (and some other image editing programs) the caption is saved in a special spot in the imaged header section called IPTC data.

While creating the IPTC mod for the simple gallery script I had to extract the IPTC information for the title of the image. This allowed me to extract the title from Picasa and included it under my images in my gallery.

What is IPTC?

IPTC stands for International Press Telecommunications Council and is a defined set of medadata mainly used in news organizations for copyright proposes.

Basically its a standard set of attributes for an image.

Some of the attributes that are included in this standard are; datesent, timesent, objectname, editstatus, urgency, category, subcategory, fixture, keyword, reldate, reltime, specinstr, credate, cretime, orgprg, prgver, byline, bytitle, city, sublocation, state, countrycode, countryname, orgtransref, headline, credit, source, copyright, contact, caption, captionwriter, imagetype, orientation, language, subfile, appreserve. for a full list see the REF document on IPTC.

How to I extract IPTC information from an image?

Extracting and altering IPTC information in PHP is very simple with IPTCParse() and IPTCEmbed()

Example: View all available IPCT Data

function output_iptc_data( $image_path ) {
    $size = getimagesize ( $image_path, $info);
    if(is_array($info)) {
        $iptc = iptcparse($info["APP13"]);
        foreach (array_keys($iptc) as $s) {
            $c = count ($iptc[$s]);
            for ($i=0; $i <$c; $i++)
            {
                echo $s.' = '.$iptc[$s][$i].'<br>';
            }
        }
    }
}

3 Responses to “Extracting the IPTC data from an image in PHP”

This Week’s Del.icio.us bookmarks | ABlueStarMarch 29th, 2007 at 9:04 am

[...] Extracting the IPTC data from an image in PHP | ABlueStar When you add a caption to an image in Google’s Picasa/Picasa2 (and some other image editing programs) the caption is saved in a special spot in the imaged header section called IPTC data. Tagged as: google iptc php picasa2 abluestar.com [...]

Confluence: Project ManagementNovember 18th, 2009 at 2:29 pm

Image Metadata…

We need to come up with a way for editors, producers, and others to submit images to Merlin as part of their workflow in producing stories. One requirement is to make sure that Merlin images have the proper metadata…….

Leave a Response

Add Tag

Tags: