IPTC "plugin"

I found Thinkdream's EXIF gizmo (inhis theme and posted on this forum). Has anyone yet found a similar way to display IPTC info?

I found a thing for folderblog (http://elwing.byethost.com/journal/?page_id=25) and a similar one for PixelPost. But I like ZenPhoto's albums and FTP-ability, so it'd be great if anyone figured it out here...

Comments

  • Jimhere-

    Here's what I had working, you might be able to make something of it:

    // IPTC Data Information for EXIF Display

    function output_iptc_data( $image_path ) {
    // --------- Set up Array Functions --------- //

    $iptcTags = array (

    "2#000" => "Record Version",
    "2#003" => "Object Type Reference",
    "2#005" => "Object Name (Title)",
    "2#007" => "Edit Status",
    "2#008" => "Editorial Update",
    "2#010" => "Urgency",
    "2#012" => "Subject Reference",
    "2#015" => "Category",
    "2#020" => "Supplemental Category",
    "2#022" => "Fixture Identifier",
    "2#025" => "Keywords",
    "2#026" => "Content Location Code",
    "2#027" => "Content Location Name",
    "2#030" => "Release Date",
    "2#035" => "Release Time",
    "2#037" => "Expiration Date",
    "2#035" => "Expiration Time",
    "2#040" => "Special Instructions",
    "2#042" => "Action Advised",
    "2#045" => "Reference Service",
    "2#047" => "Reference Date",
    "2#050" => "Reference Number",
    "2#055" => "Date Created",
    "2#060" => "Time Created",
    "2#062" => "Digital Creation Date",
    "2#063" => "Digital Creation Time",
    "2#065" => "Originating Program",
    "2#070" => "Program Version",
    "2#075" => "Object Cycle",
    "2#080" => "By-Line (Author)",
    "2#085" => "By-Line Title (Author Position) [Not used in Photoshop 7]",
    "2#090" => "City",
    "2#092" => "Sub-Location",
    "2#095" => "Province/State",
    "2#100" => "Country/Primary Location Code",
    "2#101" => "Country/Primary Location Name",
    "2#103" => "Original Transmission Reference",
    "2#105" => "Headline",
    "2#110" => "Credit",
    "2#115" => "Source",
    "2#116" => "Copyright Notice",
    "2#118" => "Contact",
    "2#120" => "Caption/Abstract",
    "2#122" => "Caption Writer/Editor",
    "2#125" => "Rasterized Caption",
    "2#130" => "Image Type",
    "2#131" => "Image Orientation",
    "2#135" => "Language Identifier",
    "2#150" => "Audio Type",
    "2#151" => "Audio Sampling Rate",
    "2#152" => "Audio Sampling Resolution",
    "2#153" => "Audio Duration",
    "2#154" => "Audio Outcue",
    "2#200" => "ObjectData Preview File Format",
    "2#201" => "ObjectData Preview File Format Version",
    "2#202" => "ObjectData Preview Data"

    );

    $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 '
    '.$iptcTags[$s].' = '.$iptc[$s][$i].'
    ';
    }
    }
    }
    }
  • In retrospect, it doesn't really do a whole lot, but it does display IPTC data.
  • Thanks. Would I paste this into a new "iptc.inc.php" doc in your theme? I see you put `require_once("exif.inc.php");` in your thinkdreams-functions.php do I repeat that?

    Also, I'd probably delete most of the IPTC tags since I'm only intererested in Keywords, Locations, and Captions.

    It surprises me that all these PhotoBlog apps are focused on the gear (exif) rather than content (iptc).
  • put the whole output_iptc_data function (including the array) into your functions.php file. you then need to call it from somewhere in your image.php file, and pass it the image information.

    i would guess that exif is much more beneficial to most users, as the IPTC assumes the user is outputting information from an image editor, rather than EXIF which is directly from a camera. Most people aren't willing to take the time to edit the IPTC tags unless they are graphic designers or artists. The EXIF tags in most cases (provided you have a compatible camera) are always there.
  • IPTC support is actually a critical feature from my perspective: I have a large number of images with IPTC caption data, and the prospect of re-entering that information manually is daunting.

    Eventually, I'd like to see title and description read into the DB automatically when a photo is uploaded, but until then, some kind of template functions to selectively display IPTC fields would do the trick.

    Any further developments with this code, thinkdreams? It looks like it just loops through all available IPTC data. Is there any way to tell it to print only certain fields?
  • Nope. I really abandoned that code direction when Tris started moving toward his own EXIF library direction. The EXIF library that is in the code now I don't think has any IPTC functionality, which means a separate IPTC library might be the way to go.
  • Cool, I'll see if I can hack your code into an interim solution for now. I don't have the php savvy to implement a whole new external library.
  • @thinkdreams,

    do you recall what needs to be passed to `output_iptc_data();` It's taking $image_path as an argument, but I don't know what to use in my image.php file to pass the required info.

    Thanks.
  • @dspnorman-

    One thing you might want to look at, not trying to add yet another library for consideration, is: http://www.ozhiker.com/electronics/pjmt/

    It's one I looked at a while back, and does lots of different metadata formats. Might be just the ticket for you to add IPTC capability.

    To answer your other question, you can try `"../" . getFullImageURL()` (or some variation thereof) and that may be just the ticket. That function returns the image URL which you should be able to pass to the function. It's the same path I used for my old EXIF function to feed it the image URL for EXIF tag reading.
  • Note also that in the IPTC function I mentioned above in the very beginning of this post, it uses a built-in PHP library (not an external library) to handle IPTC tags. Thus, this would assume that people who use it have the library compiled in their PHP setup, which is why it was decided to go with an external library for EXIF. So eventually, you'd want to look at an external library.
  • Thanks thinkdreams.

    That library appears to be offline for the time being...

    It looks like my host doesn't have the IPTC module compiled. When I run your code, I get:

    `Warning: array_keys() [function.array-keys]: The first argument should be an array in /full/path/zentest/trunk/zen/exif/makers/iptc.php on line 67

    Warning: Invalid argument supplied for foreach() in /full/path/zentest/trunk/zen/exif/makers/iptc.php on line 67`

    I've contacted them to see if they'll compile it for me.
  • Update: IPTC support was working, but my test image had no data. Oops!

    I've got the script working now in a very rudimentary form, will post when I work out a method for extracting desired data for display.
  • Alright, I've got a decent function to display IPTC title and description info.

    If the image doesn't have IPTC tags, the script falls back on zen template functions to display title and description from the database.

    Get the code here: Ticket #100

    Thanks to thinkdreams for doing the initial research and building the array to index IPTC tag names.

    The functions are pretty tailored for displaying IPTC data, but if someone wants to tear this up and see if they can read IPTC title/description during upload, and write it to the database, that would be the logical next step.

    For now, though, this should work well enough for those of you who use IPTC on the desktop and don't want to re-enter the info in zenphoto.
  • Should have mentioned, I wrote and tested this on the current SVN code, but see no reason it should not also work with the current 1.0.8.2 release. The IPTC is actually parsed by a native PHP library, and there's no reliance on any of the newer EXIF support in zenphoto. Really, it's a bare bones hack. :)
  • trisweb Administrator
    Is there a reason you didn't use the existing EXIF/IPTC library already in SVN? AFAIK it works quite well for IPTC data as well as EXIF....
  • tris-

    I wasn't aware the IPTC parsing capability was available in the svn exif code, i'll have to investigate that further. That would be really cool.
  • Likewise, I didn't know the library supported IPTC. I'm under no illusion that this anything but a hack -- if there's a better way of implementing IPTC display, I'll investigate.
  • @ds-

    i'll be taking a peek too. we'll compare notes and see if we can come up with a way to integrate it into the exifixer libs in the SVN.
  • Well, so far I've found some mentions of IPTC in Exifer, but haven't found an easy way to pull IPTC data. All the existing functions seem to deal with a pretty specific set of EXIF tags defined in an array.
  • @dspnorman-

    as of v1.5 of exifixer, it does parse the raw data, i think it might be as simple as creating lookups for the iptc data as well. Might be as simple as returning the $result array and seeing what's in there, especially using an image with IPTC tags in it, so we can get an idea of the raw data.
  • Has anyone figured out how to display the title and caption from iptc yet? I used the iptc.php file uploaded to trac but when I used the mentioned tags all I receive is blank space.
  • aitf311, can you link to an image in your gallery that has this problem?
  • dspnorman,

    This image should have keywords, title, caption embedded in it. I am including your file in my functions.php page and using the function getIPTC('title');
  • That's strange. Have you tried entering a title or description in the zenphoto data for the image? If the function can't show IPTC, it will fall back on whatever is stored in the database, so you should not be getting a blank.

    It could be that your Canon stores the tags differently than my Nikon, and the IPTC parser in PHP doesn't know how to extract them... I have to confess I have no idea how portable the $iptcTags array is, or if there's a better way of getting at the tag data. I'll try and chase down some documentation on the iptc parser.
  • With this hack active I cannot even see the scriptaculious yellow hover to add a title to the image. If you come up with anything else just let me know and I will try it.
Sign In or Register to comment.