[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/graphics/digikam/libs/dmetadata
From:       Marcel Wiesweg <marcel.wiesweg () gmx ! de>
Date:       2006-07-31 21:22:23
Message-ID: 1154380943.595273.18600.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 568344 by mwiesweg:

Older Exiv2 versions throw an error when they encounter Minolta Makernote key names.
Only query these keys if they are supported by Exiv2.
Otherwise, the Exif.Image.Orientation tag will be ignored as well.

CCBUGS: 131532, 131603



 M  +50 -34    dmetadata.cpp  


--- trunk/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp #568343:568344
@@ -550,8 +550,21 @@
     if (d->exifMetadata.empty())
        return ORIENTATION_UNSPECIFIED;
 
+    // Workaround for older Exiv2 versions which do not support
+    // Minolta Makernotes and throw an error for such keys.
+    bool supportMinolta = true;
     try
-    {   
+    {
+        Exiv2::ExifKey minoltaKey1("Exif.MinoltaCs7D.Rotation");
+        Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
+    }
+    catch( Exiv2::Error &e )
+    {
+        supportMinolta = false;
+    }
+
+    try
+    {
         Exiv2::ExifData exifData(d->exifMetadata);
         Exiv2::ExifData::iterator it;
         long orientation;
@@ -562,49 +575,52 @@
 
         // -- Minolta Cameras ----------------------------------
 
-        Exiv2::ExifKey minoltaKey1("Exif.MinoltaCs7D.Rotation");
-        it = exifData.findKey(minoltaKey1);
-        
-        if (it != exifData.end())
+        if (supportMinolta)
         {
-            orientation = it->toLong();
-            kdDebug() << "Minolta Makernote Orientation: " << orientation << endl;
-            switch(orientation)
+            Exiv2::ExifKey minoltaKey1("Exif.MinoltaCs7D.Rotation");
+            it = exifData.findKey(minoltaKey1);
+
+            if (it != exifData.end())
             {
-                case 76:
-                    imageOrient = ORIENTATION_ROT_90;
-                    break;
-                case 82:
-                    imageOrient = ORIENTATION_ROT_270;
-                    break;
+                orientation = it->toLong();
+                kdDebug() << "Minolta Makernote Orientation: " << orientation << endl;
+                switch(orientation)
+                {
+                    case 76:
+                        imageOrient = ORIENTATION_ROT_90;
+                        break;
+                    case 82:
+                        imageOrient = ORIENTATION_ROT_270;
+                        break;
+                }
+                return imageOrient;
             }
-            return imageOrient;
-        }
 
-        Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
-        it = exifData.findKey(minoltaKey2);
-        
-        if (it != exifData.end())
-        {
-            orientation = it->toLong();
-            kdDebug() << "Minolta Makernote Orientation: " << orientation << endl;
-            switch(orientation)
+            Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
+            it = exifData.findKey(minoltaKey2);
+
+            if (it != exifData.end())
             {
-                case 76:
-                    imageOrient = ORIENTATION_ROT_90;
-                    break;
-                case 82:
-                    imageOrient = ORIENTATION_ROT_270;
-                    break;
+                orientation = it->toLong();
+                kdDebug() << "Minolta Makernote Orientation: " << orientation << endl;
+                switch(orientation)
+                {
+                    case 76:
+                        imageOrient = ORIENTATION_ROT_90;
+                        break;
+                    case 82:
+                        imageOrient = ORIENTATION_ROT_270;
+                        break;
+                }
+                return imageOrient;
             }
-            return imageOrient;
         }
 
         // -- Standard Exif tag --------------------------------
 
         Exiv2::ExifKey keyStd("Exif.Image.Orientation");
         it = exifData.findKey(keyStd);
-        
+
         if (it != exifData.end())
         {
             orientation = it->toLong();
@@ -617,8 +633,8 @@
         kdDebug() << "Cannot parse Exif Orientation tag using Exiv2 (" 
                   << QString::fromLocal8Bit(e.what().c_str())
                   << ")" << endl;
-    }        
-    
+    }
+
     return ORIENTATION_UNSPECIFIED;
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic