diff options
author | Silvio <s1lv10@uol.com.br> | 2010-04-27 17:48:24 -0300 |
---|---|---|
committer | Silvio <s1lv10@uol.com.br> | 2010-04-27 17:48:24 -0300 |
commit | 46ba9330eeb9a0c46af5785d784499c6a4c6c614 (patch) | |
tree | b60fc08a0c762076744f3e3fe7c290ba7fd49c10 | |
parent | 32aa71f1f93e0acd8095b82a919d5ab589c02eea (diff) | |
download | exif-46ba9330eeb9a0c46af5785d784499c6a4c6c614.tar.gz exif-46ba9330eeb9a0c46af5785d784499c6a4c6c614.tar.bz2 |
Error checking when getting metadata
-rw-r--r-- | exif.class.php | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/exif.class.php b/exif.class.php index 34da3cd..62f01c5 100644 --- a/exif.class.php +++ b/exif.class.php @@ -137,17 +137,20 @@ Class Exif { $xmp = $this->openXMP($file); $info = array(); - // Iterate over XMP fields defined by CCK. - foreach ($arTagNames as $tagName) { - if ($tagName['section'] == "xmp") { - // Get XMP field. - $config = $map[$tagName['tag']]; - $field = $this->readXMPItem($xmp, $config); - $info[$tagName['section'] .'_'. $tagName['tag']] = $field; + if ($xmp != FALSE) { + // Iterate over XMP fields defined by CCK. + foreach ($arTagNames as $tagName) { + if ($tagName['section'] == "xmp") { + // Get XMP field. + $config = $map[$tagName['tag']]; + $field = $this->readXMPItem($xmp, $config); + $info[$tagName['section'] .'_'. $tagName['tag']] = $field; + } } + + $this->closeXMP($xmp); } - $this->closeXMP($xmp); return $info; } @@ -161,15 +164,20 @@ Class Exif { * Array with XMP file and metadata. */ function openXMP($file) { - // Setup + // Setup. $xmpfiles = new SXMPFiles(); $xmpmeta = new SXMPMeta(); - // Open + // Open. $xmpfiles->OpenFile($file); - $xmpfiles->GetXMP($xmpmeta); - return array('files' => $xmpfiles, 'meta' => $xmpmeta); + // Get XMP metadata into the object. + if ($xmpfiles->GetXMP($xmpmeta)) { + return array('files' => $xmpfiles, 'meta' => $xmpmeta); + } + + // No XMP data available. + return FALSE; } /** @@ -309,6 +317,11 @@ Class Exif { 'ns' => 'http://ns.adobe.com/photoshop/1.0/', 'type' => 'property', ), + 'source' => array( + 'name' => 'Source', + 'ns' => 'http://ns.adobe.com/photoshop/1.0/', + 'type' => 'property', + ), 'instructions' => array( 'name' => 'Instructions', 'ns' => 'http://ns.adobe.com/photoshop/1.0/', @@ -334,6 +347,11 @@ Class Exif { 'ns' => 'http://purl.org/dc/elements/1.1/', 'type' => 'array', ), + 'title' => array( + 'name' => 'title', + 'ns' => 'http://purl.org/dc/elements/1.1/', + 'type' => 'array', + ), 'ciadrextadr' => array( 'name' => 'CiAdrExtadr', 'ns' => 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/', @@ -357,6 +375,11 @@ Class Exif { 'ns' => 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/', 'type' => 'array', ), + 'subjectcode' => array( + 'name' => 'SubjectCode', + 'ns' => 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/', + 'type' => 'array', + ), 'hierarchicalsubject' => array( 'name' => 'hierarchicalSubject', 'ns' => 'http://ns.adobe.com/lightroom/1.0/', |