note 32622 added to function.iptcparse

From: Date: Tue, 03 Jun 2003 10:11:30 +0000
Subject: note 32622 added to function.iptcparse
Groups: php.notes 
Request: Send a blank email to php-notes+get-49607@lists.php.net to get a copy of this message
Here´s a little function to return a more comfortable associative array of IPTC fields in an image. Probably not perfect but working for me... of course I used the examples from the above posters as a starter - thanks for that! --- code --- // getiptcinfo(pathtoimage) // returns associative array of IPTC-Header if available, or false on failure // hash fields are named as specified in IPTC sample c++ code // see http://www.iptc.org/site/iimphotocpp.zip // function getiptcinfo($imagepath) { // $_iptcmap is a hash of IPTC-codes resolving to names $_iptcmap=Array("2#120"=>"caption", "2#005"=>"graphic_name", "2#010"=>"urgency", "2#015"=>"category", "2#020"=>"supp_categories", "2#025"=>"keywords", "2#040"=>"spec_instr", "2#055"=>"creation_date", "2#060"=>"creation_time", "2#065"=>"orig_program", "2#080"=>"byline", "2#085"=>"bytitle", "2#090"=>"city", "2#095"=>"state", "2#095"=>"country", "2#101"=>"country", "2#103"=>"transref", "2#105"=>"headline", "2#110"=>"credit", "2#115"=>"source", "2#120"=>"caption", "2#122"=>"caption_writer"); if(is_readable($imagepath)) { $size = GetImageSize($imagepath,&$myinfo); if($myinfo["APP13"]) { $iptc = iptcparse ($myinfo["APP13"]); if(is_array($iptc)) { $retval=array(); foreach($iptc as $iptckey=>$iptcvalue) { $temp=''; if(is_array($iptcvalue)) { if(count($iptcvalue)>1) { $temp=$iptcvalue; } else { $temp=$iptcvalue[0]; } if($_iptcmap[$iptckey]) { $retval[$_iptcmap[$iptckey]]=$temp; } else { if(preg_match("/\#(\d+)/",$iptckey,$match)) { $retval[$match[1]]=$temp; } else { $retval[$iptckey]=$temp; } } } } } else { $retval=false; } } else { $retval=false; } } else { $retval=false; } return $retval; } ---- Manual Page -- http://www.php.net/manual/en/function.iptcparse.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32622 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32622&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32622&report=yes

« previous php.notes (#49607) next »