aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exif.class.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/exif.class.php b/exif.class.php
index 62f01c5..3913927 100644
--- a/exif.class.php
+++ b/exif.class.php
@@ -173,6 +173,9 @@ Class Exif {
// Get XMP metadata into the object.
if ($xmpfiles->GetXMP($xmpmeta)) {
+ // Sort metadata.
+ $xmpmeta->Sort();
+
return array('files' => $xmpfiles, 'meta' => $xmpmeta);
}
@@ -210,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;