[Digikam-devel] [Bug 131603] Orientation of RAW-images (especially Canons *.cr2)

Gilles Caulier caulier.gilles at free.fr
Thu Aug 17 13:39:00 BST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=131603         




------- Additional Comments From caulier.gilles free fr  2006-08-17 14:38 -------
SVN commit 573883 by cgilles:

digikam from trunk: Bug fix: with Minolta camera (Dynax5D and 7D), we need to set the Minolta Makernote Orientation tag to "Normal" 
when we set the Exif orientation tag, else preview and thumb will not be orientated properlly after to have created a new image 
from editor using a Minolta picture.
CCBUGS: 131603, 131532



 M  +44 -0     dmetadata.cpp  


--- trunk/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp #573882:573883
 @ -643,7 +643,20  @
     if (d->exifMetadata.empty())
        return false;
 
+    // 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
     {    
         if (orientation < ORIENTATION_UNSPECIFIED || orientation > ORIENTATION_ROT_270)
         {
 @ -653,6 +666,37  @
         
         d->exifMetadata["Exif.Image.Orientation"] = (uint16_t)orientation;
         kdDebug() << "Exif orientation tag set to: " << orientation << endl;
+
+        // -- Minolta Cameras ----------------------------------
+
+        if (supportMinolta)
+        {
+            uint16_t MinoltaOrientation = 72;    // Horizontal (Normal)
+            switch((uint16_t)orientation)
+            {    
+                case ORIENTATION_ROT_90:
+                        MinoltaOrientation = 76; // Rotate 90 CW
+                    break;
+        
+                case ORIENTATION_ROT_270:
+                        MinoltaOrientation = 82; // Rotate 180 CW
+                    break;
+            }
+    
+            Exiv2::ExifData exifData(d->exifMetadata);
+            Exiv2::ExifData::iterator it;
+
+            Exiv2::ExifKey minoltaKey1("Exif.MinoltaCs7D.Rotation");
+            it = exifData.findKey(minoltaKey1);
+            if (it != exifData.end())
+                d->exifMetadata["Exif.MinoltaCs7D.Rotation"] = MinoltaOrientation;
+        
+            Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
+            it = exifData.findKey(minoltaKey2);
+            if (it != exifData.end())
+                d->exifMetadata["Exif.MinoltaCs5D.Rotation"] = MinoltaOrientation;
+        }
+
         return true;
     }
     catch( Exiv2::Error &e )



More information about the Digikam-devel mailing list