[Digikam-devel] [Bug 131532] Minolta exception code can break EXIF rotation

Marcel Wiesweg marcel.wiesweg at gmx.de
Mon Jul 31 22:40:35 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=131532         




------- Additional Comments From marcel.wiesweg gmx de  2006-07-31 23:40 -------
SVN commit 568351 by mwiesweg:

Rotate RAW thumbnails as well, not only JPEGs contains rotation information.

CCBUGS: 131532, 131603


 M  +38 -47    digikamthumbnail.cpp  


--- trunk/extragear/graphics/digikam/kioslave/digikamthumbnail.cpp #568350:568351
 @ -422,65 +422,56  @
 
 void kio_digikamthumbnailProtocol::exifRotate(const QString& filePath, QImage& thumb)
 {
-    // Check if the file is an JPEG image
-    KFileMetaInfo metaInfo(filePath, "image/jpeg", KFileMetaInfo::Fastest);
+    // Rotate thumbnail based on metadata orientation information
 
-    if (metaInfo.isValid())
-    {
-        if (metaInfo.mimeType() == "image/jpeg" &&
-            metaInfo.containsGroup("Jpeg EXIF Data"))
-        {
-            // Rotate thumbnail from JPEG files based on EXIF rotate tag
+    DMetadata metadata(filePath);
+    DMetadata::ImageOrientation orientation = metadata.getImageOrientation();
 
-            QWMatrix matrix;
-            DMetadata metadata(filePath);
-            DMetadata::ImageOrientation orientation = metadata.getImageOrientation();
+    if (orientation == DMetadata::ORIENTATION_NORMAL ||
+        orientation == DMetadata::ORIENTATION_UNSPECIFIED)
+        return;
 
-            bool doXform = (orientation != DMetadata::ORIENTATION_NORMAL &&
-                            orientation != DMetadata::ORIENTATION_UNSPECIFIED);
+    QWMatrix matrix;
 
-            switch (orientation) 
-            {
-                case DMetadata::ORIENTATION_NORMAL:
-                case DMetadata::ORIENTATION_UNSPECIFIED:
-                    break;
+    switch (orientation)
+    {
+        case DMetadata::ORIENTATION_NORMAL:
+        case DMetadata::ORIENTATION_UNSPECIFIED:
+            break;
 
-                case DMetadata::ORIENTATION_HFLIP:
-                    matrix.scale(-1, 1);
-                    break;
+        case DMetadata::ORIENTATION_HFLIP:
+            matrix.scale(-1, 1);
+            break;
 
-                case DMetadata::ORIENTATION_ROT_180:
-                    matrix.rotate(180);
-                    break;
+        case DMetadata::ORIENTATION_ROT_180:
+            matrix.rotate(180);
+            break;
 
-                case DMetadata::ORIENTATION_VFLIP:
-                    matrix.scale(1, -1);
-                    break;
+        case DMetadata::ORIENTATION_VFLIP:
+            matrix.scale(1, -1);
+            break;
 
-                case DMetadata::ORIENTATION_ROT_90_HFLIP:
-                    matrix.scale(-1, 1);
-                    matrix.rotate(90);
-                    break;
+        case DMetadata::ORIENTATION_ROT_90_HFLIP:
+            matrix.scale(-1, 1);
+            matrix.rotate(90);
+            break;
 
-                case DMetadata::ORIENTATION_ROT_90:
-                    matrix.rotate(90);
-                    break;
+        case DMetadata::ORIENTATION_ROT_90:
+            matrix.rotate(90);
+            break;
 
-                case DMetadata::ORIENTATION_ROT_90_VFLIP:
-                    matrix.scale(1, -1);
-                    matrix.rotate(90);
-                    break;
+        case DMetadata::ORIENTATION_ROT_90_VFLIP:
+            matrix.scale(1, -1);
+            matrix.rotate(90);
+            break;
 
-                case DMetadata::ORIENTATION_ROT_270:
-                    matrix.rotate(270);
-                    break;
-            }
-
-            //transform accordingly
-            if ( doXform )
-                thumb = thumb.xForm( matrix );
-        }
+        case DMetadata::ORIENTATION_ROT_270:
+            matrix.rotate(270);
+            break;
     }
+
+    // transform accordingly
+    thumb = thumb.xForm( matrix );
 }
 
 QImage kio_digikamthumbnailProtocol::loadPNG(const QString& path)



More information about the Digikam-devel mailing list