Bug 127577 - raw display too dark and not rotated
Summary: raw display too dark and not rotated
Status: RESOLVED WORKSFORME
Alias: None
Product: digikam
Classification: Unclassified
Component: Plugin-RawImport-Native (show other bugs)
Version: unspecified
Platform: openSUSE RPMs Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-18 13:50 UTC by Daniel Bauer
Modified: 2022-01-26 04:23 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.9.0


Attachments
dark unrotated sample from 0.9.0_svn (627.48 KB, image/png)
2006-05-18 13:53 UTC, Daniel Bauer
Details
album preview (correct brightness but unrotated) in 0.9.0 svn (34.39 KB, image/png)
2006-05-18 13:55 UTC, Daniel Bauer
Details
same photo in 0.8.1 editor(correct brightness + rotated) (577.77 KB, image/png)
2006-05-18 13:56 UTC, Daniel Bauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bauer 2006-05-18 13:50:13 UTC
Version:           0.9.0 svn (using KDE KDE 3.5.2)
Installed from:    SuSE RPMs
OS:                Linux

When displaying a Canon CR2 raw file in the image editor of svn 9.0 it appears extremely dark.

Also the raw image is not rotated in album and editor (0.8.1 editor did correct rotation, but 0.8.1 album preview was also not rotated).

The previews in the album view are normal in brightness (same as in 0.8.1). The tool "extras/convert-single-raw" gives the correct result in brightness and rotation (as Ufraw does, too).

In 0.8.1 editor the picture was shown correct. I used a copy of the same file for the test to compare. I'll send samples.
Comment 1 Daniel Bauer 2006-05-18 13:53:35 UTC
Created attachment 16154 [details]
dark unrotated sample from 0.9.0_svn
Comment 2 Daniel Bauer 2006-05-18 13:55:13 UTC
Created attachment 16155 [details]
album preview (correct brightness but unrotated) in 0.9.0 svn
Comment 3 Daniel Bauer 2006-05-18 13:56:58 UTC
Created attachment 16156 [details]
same photo in 0.8.1 editor(correct brightness + rotated)
Comment 4 Loïc Brarda 2006-05-18 15:04:40 UTC
I've the same problem with MRW files from Dynax5D.
Comment 5 caulier.gilles 2006-05-18 16:11:18 UTC
Daniel, 

this is not a bug. 0.9.0 is completly different than 0.8.x release about RAW files support :

==> 0.8.x support only RAW image in 8bits per color per pixel
==> 0.9.0 support RAW file in 16 bits !!!

with 0.8.x, dcraw extract image data to compensate automaticly exposure. it's simple and enough with 8 bits images.

with 0.9.0, dcraw extract image data in linear mode to unlost image color data depth. To have the right exposure, you need to use ICC color profile management !!!

With my Minolta Dynax5D, i use icc color profiles provides with my camera (*.icc). I set the right icc color profile in ICC setup, and that all !

A screenshot : http://digikam3rdparty.free.fr/Screenshots/iccworkflowwithrawimages.png

I have started since sometime an icc color profile repository with Paco (another digiKAm developper who have works into icc management). Take a look here :

http://digikam3rdparty.free.fr/ICCPROFILES/

ALL contributions welcome about this repository ! If you have anothers icc file to place in this area, let's me hear !

Gilles Caulier


Comment 6 glaurent 2006-05-18 16:25:56 UTC
These files should be part of the digikam package IMHO.
Comment 7 caulier.gilles 2006-05-18 16:31:16 UTC
impossible ! These file are copyrighted ! The only solution is to make a web space repository to download outside digikam.

I have seen that krita include some icc profiles (available in svn!!!). It's very _DANGEROUS_ with the law ! 

ICC profiles files aren't free software. Take a care !!!

Gilles Caulier
Comment 8 glaurent 2006-05-18 16:36:54 UTC
Distributing them in a tarball is forbidden, but making them freely available on a website is not ? Sounds a bit odd to me.
Comment 9 caulier.gilles 2006-05-18 16:40:31 UTC
Distributing a tarball cannot be done by digikam team. It's the responsability of packager (linux dist) to do it.

Gilles
Comment 10 caulier.gilles 2006-05-18 16:49:39 UTC
SVN commit 542179 by cgilles:

digikam from trunk : do not perform auto-rotation with RAW files in editor (dcraw will perform this job automaticly), but only auto-rotate JPEG files.

TODO: check if TIFF/EP files can be procressed likeJPEG here.

CCBUGS: 127577
CCMAIL: digikam-devel@kde.org

 M  +3 -1      dimginterface.cpp  


--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #542178:542179
@@ -390,7 +390,9 @@
         valRet = false;
     }
 
-    if (d->exifOrient)
+    // Raw file are already rotated properlly by dcraw. Only rotate JPEG file.
+    // TODO support TIFF/EP file here like JPEG.
+    if (d->exifOrient && d->image.attribute("format").toString() == QString("JPEG"))
         exifRotate(d->filename);
     
     emit signalImageLoaded(d->filename, valRet);
Comment 11 Matthias Wieser 2006-05-18 17:36:46 UTC
Distributing MP3s as a tar ball is forbidden, but putting them on a webserver is allowed??

Anyway, Digikam should at least provide a standard profile (that one that dcraw uses for it's 8bit mode) which gives usable results.

Additional profiles could be made available by get-hot-new-stuff.
http://dot.kde.org/1110652641/
Comment 12 caulier.gilles 2006-05-18 18:59:55 UTC
SVN commit 542230 by cgilles:

digikam from trunk : thumb kio slave : only perform Exif based auto-rotation on JPEG files, not RAW.
CCBUGS: 127577 

 M  +78 -68    digikamthumbnail.cpp  


--- trunk/extragear/graphics/digikam/kioslave/digikamthumbnail.cpp #542229:542230
@@ -21,6 +21,7 @@
  * ============================================================ */
 
 #define XMD_H
+#define PNG_BYTES_TO_CHECK 4
 
 // C++ includes.
 
@@ -58,6 +59,7 @@
 #include <kprocess.h>
 #include <kio/global.h>
 #include <kio/thumbcreator.h>
+#include <kfilemetainfo.h>
 
 // Local includes
 
@@ -84,71 +86,81 @@
 using namespace KIO;
 using namespace Digikam;
 
-static void exifRotate(const QString& filePath, QImage& thumb)
+// TODO : check if it's necessary to have a static method here!
+void exifRotate(const QString& filePath, QImage& thumb)
 {
-    // Rotate thumbnail based on EXIF rotate tag
+    // Check if the file is an JPEG image
+    KFileMetaInfo metaInfo(filePath, "image/jpeg", KFileMetaInfo::Fastest);
 
-    QWMatrix matrix;
-    DMetadata metadata(filePath);
-    DMetadata::ImageOrientation orientation = metadata.getImageOrientation();
-    
-    bool doXform = (orientation != DMetadata::ORIENTATION_NORMAL &&
-                    orientation != DMetadata::ORIENTATION_UNSPECIFIED);
-
-    switch (orientation) 
+    if (metaInfo.isValid())
     {
-       case DMetadata::ORIENTATION_NORMAL:
-       case DMetadata::ORIENTATION_UNSPECIFIED:
-          break;
-
-       case DMetadata::ORIENTATION_HFLIP:
-          matrix.scale(-1,1);
-          break;
-
-       case DMetadata::ORIENTATION_ROT_180:
-          matrix.rotate(180);
-          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:
-          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;
+        if (metaInfo.mimeType() == "image/jpeg" &&
+            metaInfo.containsGroup("Jpeg EXIF Data"))
+        {   
+            // Rotate thumbnail from JPEG files based on EXIF rotate tag
+        
+            QWMatrix matrix;
+            DMetadata metadata(filePath);
+            DMetadata::ImageOrientation orientation = metadata.getImageOrientation();
+            
+            bool doXform = (orientation != DMetadata::ORIENTATION_NORMAL &&
+                            orientation != DMetadata::ORIENTATION_UNSPECIFIED);
+        
+            switch (orientation) 
+            {
+                case DMetadata::ORIENTATION_NORMAL:
+                case DMetadata::ORIENTATION_UNSPECIFIED:
+                    break;
+            
+                case DMetadata::ORIENTATION_HFLIP:
+                    matrix.scale(-1,1);
+                    break;
+            
+                case DMetadata::ORIENTATION_ROT_180:
+                    matrix.rotate(180);
+                    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:
+                    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 );
+        }
     }
-
-    //transform accordingly
-    if ( doXform )
-       thumb = thumb.xForm( matrix );
 }
 
-#define PNG_BYTES_TO_CHECK 4
-
+// TODO : check if it's necessary to have a static method here!
 static QImage loadPNG(const QString& path)
 {
-    png_uint_32         w32, h32;
-    int                 w, h;
-    bool                has_alpha;
-    bool                has_grey;
-    FILE               *f;
-    png_structp         png_ptr = NULL;
-    png_infop           info_ptr = NULL;
-    int                 bit_depth, color_type, interlace_type;
+    png_uint_32  w32, h32;
+    int          w, h;
+    bool         has_alpha;
+    bool         has_grey;
+    FILE        *f;
+    png_structp  png_ptr = NULL;
+    png_infop    info_ptr = NULL;
+    int          bit_depth, color_type, interlace_type;
 
     has_alpha = 0;
     has_grey  = 0;
@@ -159,7 +171,7 @@
     if (!f)
         return qimage;
 
-    unsigned char       buf[PNG_BYTES_TO_CHECK];
+    unsigned char buf[PNG_BYTES_TO_CHECK];
 
     fread(buf, 1, PNG_BYTES_TO_CHECK, f);
     if (!png_check_sig(buf, PNG_BYTES_TO_CHECK))
@@ -217,8 +229,8 @@
     if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)
         has_grey = 1;
 
-    unsigned char     **lines;
-    int                 i;
+    unsigned char **lines;
+    int             i;
 
     if (has_alpha)
         png_set_expand(png_ptr);
@@ -451,8 +463,7 @@
     return false;
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
-// JPEG Extraction
+// -- JPEG Extraction ---------------------------------------------------------------------
 
 struct myjpeg_error_mgr : public jpeg_error_mgr
 {
@@ -604,8 +615,7 @@
     return true;
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
-// Load using DImg
+// -- Load using DImg ---------------------------------------------------------------------
 
 bool kio_digikamthumbnailProtocol::loadDImg(QImage& image, const QString& path)
 {
@@ -635,8 +645,7 @@
     return true;
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
-// Load using Dcraw
+// -- Load using Dcraw ---------------------------------------------------------------------
 
 bool kio_digikamthumbnailProtocol::loadDCRAW(QImage& image, const QString& path)
 {
@@ -709,6 +718,8 @@
     return true;
 }
 
+// -- Load using KDE API ---------------------------------------------------------------------
+
 bool kio_digikamthumbnailProtocol::loadKDEThumbCreator(QImage& image, const QString& path)
 {
     // this sucks royally. some of the thumbcreators need an instance of
@@ -791,8 +802,7 @@
     KStandardDirs::makeDir(bigThumbPath_, 0700);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
-// KIO slave registration
+// -- KIO slave registration ---------------------------------------------------------------------
 
 extern "C"
 {
Comment 13 caulier.gilles 2006-05-18 19:24:25 UTC
Exif auto-rotation is fixed in 0.9.0 like 0.8.x does.

The problem with RAW thumb is that dcraw extract the embeded thumb from pictures as well with apply some rotation. There is no yet a solution to do it, perhaps in the future when Exiv2 will support RAW thumbnails extraction like it does with JPEG files.

Gilles
Comment 14 Mikolaj Machowski 2006-05-19 00:53:27 UTC
I have an impression that krita icc profiles *are* free but not top
quality.
Comment 15 caulier.gilles 2006-05-19 07:06:40 UTC
I agree to include some standard and free to use ICC profiles files in digikam dist. but we need to take a care about (c) and others stuff.

All suggestions welcome.

Gilles
Comment 16 Thorsten Schnebeck 2006-05-19 08:53:59 UTC
Please follow these interesting threads on openicc
http://lists.freedesktop.org/archives/openicc/2005q2/000379.html
http://lists.freedesktop.org/archives/openicc/2005q4/000668.html
Bye

  Thorsten
Comment 17 Marcus Popp 2006-06-07 23:28:45 UTC
I have a similiar problem with the rotation of raw files within the album  (0.9.0-svn).
My NEF files doesn't include the exif information in the jpeg-thumbnails.
examples: http://slave.paranoidbsd.org/photo/dsc-0002.nef
and extracted thumbnail: http://slave.paranoidbsd.org/photo/dsc-0002.dcraw-e.jpg

Or should I fill a differnt bug report?