Index: exif.class.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/exif/Attic/exif.class.php,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 exif.class.php
--- exif.class.php	27 Apr 2010 20:53:13 -0000	1.1.2.11
+++ exif.class.php	27 Apr 2010 21:28:40 -0000
@@ -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,23 @@ 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)) {
+      // Sort metadata.
+      $xmpmeta->Sort();
+
+      return array('files' => $xmpfiles, 'meta' => $xmpmeta);
+    }
+
+    // No XMP data available.
+    return FALSE;
   }
 
   /**
@@ -202,18 +213,17 @@ Class Exif {
     $xmpfiles = $xmp['files'];
     $xmpmeta  = $xmp['meta'];
 
-    // Sort.
-    $xmpmeta->Sort();
-
-    // Read XMP data.
-    if ($config['type'] == 'property') {
-      $value = @$xmpmeta->GetProperty($config['name'], $config['ns']);
-    }
-    elseif ($config['type'] == 'array') {
-      $value = @$xmpmeta->GetArrayItem($config['name'], $key, $config['ns']);
-    } 
-    elseif ($config['type'] == 'struct') {
-      $value = @$xmpmeta->GetStructField($config['ns'], $config['struct'], $config['ns'], $config['name']);
+    // Try to read XMP data if the namespace is available.
+    if(@$xmpmeta->GetNamespacePrefix($config['ns'])) {
+      if ($config['type'] == 'property') {
+        $value = @$xmpmeta->GetProperty($config['name'], $config['ns']);
+      }
+      elseif ($config['type'] == 'array') {
+        $value = @$xmpmeta->GetArrayItem($config['name'], $key, $config['ns']);
+      } 
+      elseif ($config['type'] == 'struct') {
+        $value = @$xmpmeta->GetStructField($config['ns'], $config['struct'], $config['ns'], $config['name']);
+      }
     }
 
     return $value;
@@ -309,6 +319,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 +349,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 +377,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/',
@@ -379,4 +404,4 @@ Class Exif {
       ),
     );
   }
-}
+}  
