Bug 147260 - digikam image view does not rotate images in album view, thumbs are correct
Summary: digikam image view does not rotate images in album view, thumbs are correct
Status: RESOLVED WORKSFORME
Alias: None
Product: digikam
Classification: Applications
Component: Preview-Image (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-26 19:20 UTC by Roman Fietze
Modified: 2022-01-19 16:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 7.6.0


Attachments
output of dcraw -i -v run on a sample K10D image (488 bytes, text/plain)
2007-07-01 18:05 UTC, Andrew Dodd
Details
output of exiv2 -p t run on a sample K10D image (3.31 KB, text/plain)
2007-07-01 18:05 UTC, Andrew Dodd
Details
output of dcraw -i -v on a DMC-LX1RAW converted to DNG (502 bytes, text/plain)
2007-07-01 18:06 UTC, Andrew Dodd
Details
output of exiv2 -p t on a DMC-LX1RAW converted to DNG (26.17 KB, text/plain)
2007-07-01 18:07 UTC, Andrew Dodd
Details
output of dcraw -i -v on a DMC-LX1 RAW image (502 bytes, text/plain)
2007-07-01 18:07 UTC, Andrew Dodd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Fietze 2007-06-26 19:20:49 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    SuSE RPMs

As of digikam 0.9.2-final digikam does not rotate images, neither JPEGs nor CR2s, when beiing viewed using the image pop up menu->View. The thumbnails are rotated correctly, exiftool also displays the correct Orientation tag.

When I remember it correctly this worked before.
Comment 1 Andrew Dodd 2007-07-01 05:15:42 UTC
Same occurs for the following in 0.9.2 final:
PEF files (Pentax K10D RAW files)
DNGs generated by running Adobe DNG Converter 4.1 on RAW files generated by a Panasonic Lumix DMC-LX1

It does not occur for the original RAW files generated by the DMC-LX1.

I can provide examples of all three formats upon request.  I am assuming they are too large to attach (8-10MB for PEF, 16MB for Lumix RAW, 7-8MB for Lumix "DNG from RAW"), but will attempt in a second comment.
Comment 2 Andrew Dodd 2007-07-01 18:05:06 UTC
Created attachment 21003 [details]
output of dcraw -i -v run on a sample K10D image
Comment 3 Andrew Dodd 2007-07-01 18:05:36 UTC
Created attachment 21004 [details]
output of exiv2 -p t run on a sample K10D image
Comment 4 Andrew Dodd 2007-07-01 18:06:40 UTC
Created attachment 21005 [details]
output of dcraw -i -v on a DMC-LX1RAW converted to DNG

Conversion was done by Adobe DNG Converter 4.1 running in WINE
Comment 5 Andrew Dodd 2007-07-01 18:07:13 UTC
Created attachment 21006 [details]
output of exiv2 -p t on a DMC-LX1RAW converted to DNG
Comment 6 Andrew Dodd 2007-07-01 18:07:40 UTC
Created attachment 21007 [details]
output of dcraw -i -v on a DMC-LX1 RAW image
Comment 7 Andrew Dodd 2007-07-01 18:12:25 UTC
exiv2 -p t when run on an unconverted DMC-LX1 RAW results in the following error in stderr and no output to stdout:

Exiv2 exception in print action for file P1000317.raw:
P1000317.raw: The file contains data of an unknown image type

These files are rotated correctly in digikam.  My suspicion is that if EXIF rotation information is present in the raw image, rotation is applied twice.  (Once when converted by dcraw, once more by digikam when it sees EXIF rotation information.)

I do not remember the camera orientation for the above samples, but will attempt a test to see if the problem is double rotation (resulting in a total 180 degree rotation) or no rotation later today.
Comment 8 Andrew Dodd 2007-07-01 19:09:25 UTC
It is not double rotation.  A test image taken with the K10D's grip (right side of camera when oriented normally) oriented upwards results in digikam displaying the "top" of the image at the right side in "view" mode, indicating that either no rotation is being applied, or the net effect of all rotations is that no rotation is applied.

Also, opening the image with "Edit..." results in correct orientation.
Comment 9 Andrew Dodd 2007-07-01 21:39:44 UTC
Temporary workaround:

In the "Albums" section of "Configure digiKam...", select "Embedded preview load full image size", this will cause RAW images to be rotated correctly, but will slow down browsing through albums significantly.

It appears that within exifRotate in loadsavethread.cpp, if an image is RAW it is not rotated.  For actual images converted with dcraw, this is the correct behavior.

For embedded previews extracted via kdcraw -e, this is not the correct behavior - the embedded preview is an unrotated JPEG that contains an EXIF orientation tag.

The reason the Panasonic DMC-LX1 unconverted-to-DNG raw images behaved correctly was not that they were missing EXIF data, but that they were missing embedded previews.  The Pentax PEFs and LX1 converted-to-DNG images both had embedded previews.
Comment 10 Marcel Wiesweg 2007-07-02 18:48:49 UTC
SVN commit 682425 by mwiesweg:

Handle raw embedded preview differently than raw images loaded by dcraw
(either in full or half size mode).
Thanks to Andrew Dodd for bug hunting.

CCBUG: 147260


 M  +2 -1      loadsavethread.cpp  
 M  +23 -9     previewtask.cpp  


--- branches/extragear/kde3/graphics/digikam/libs/threadimageio/loadsavethread.cpp #682424:682425
@@ -211,7 +211,8 @@
     // Raw files are already rotated properlly by dcraw. Only perform auto-rotation with JPEG/PNG/TIFF file.
     // We don't have a feedback from dcraw about auto-rotated RAW file during decoding. Return true anyway.
 
-    if (DImg::fileFormat(filePath) == DImg::RAW)
+    attribute = image.attribute("fromRawEmbeddedPreview");
+    if (DImg::fileFormat(filePath) == DImg::RAW && !(attribute.isValid() && attribute.toBool()) )
     {
         return true;
     }
--- branches/extragear/kde3/graphics/digikam/libs/threadimageio/previewtask.cpp #682424:682425
@@ -138,34 +138,48 @@
 
     DImg img;
     QImage qimage;
+    bool fromEmbeddedPreview = false;
 
     // -- Get the image preview --------------------------------
 
     // First the QImage-dependent loading methods
     // Trying to load with dcraw: RAW files.
-    if ( !KDcrawIface::KDcraw::loadDcrawPreview(qimage, m_loadingDescription.filePath) )
+    if (KDcrawIface::KDcraw::loadEmbeddedPreview(qimage, m_loadingDescription.filePath))
+        fromEmbeddedPreview = true;
+
+    if (qimage.isNull())
     {
-        // Try to extract Exif/Iptc preview.
-        loadImagePreview(qimage, m_loadingDescription.filePath);
+        //TODO: Use DImg based loader instead?
+        KDcrawIface::KDcraw::loadEmbeddedPreview(qimage, m_loadingDescription.filePath);
     }
 
-    // DImg-dependent loading methods
+    // Try to extract Exif/Iptc preview.
     if (qimage.isNull())
     {
-        // Set a hint to try to load a JPEG with the fast scale-before-decoding method
-        img.setAttribute("jpegScaledLoadingSize", size);
-        img.load(m_loadingDescription.filePath, this, m_loadingDescription.rawDecodingSettings);
+        loadImagePreview(qimage, m_loadingDescription.filePath);
     }
-    else
+
+    if (!qimage.isNull())
     {
         // convert from QImage
         img = DImg(qimage);
+        // mark as embedded preview (for exif rotation)
+        if (fromEmbeddedPreview)
+            img.setAttribute("fromRawEmbeddedPreview", true);
         // free memory
-        qimage.reset();
+        qimage = QImage();
     }
 
+    // DImg-dependent loading methods
     if (img.isNull())
     {
+        // Set a hint to try to load a JPEG with the fast scale-before-decoding method
+        img.setAttribute("jpegScaledLoadingSize", size);
+        img.load(m_loadingDescription.filePath, this, m_loadingDescription.rawDecodingSettings);
+    }
+
+    if (img.isNull())
+    {
         DWarning() << "Cannot extract preview for " << m_loadingDescription.filePath << endl;
     }
 
Comment 11 Marcel Wiesweg 2007-07-02 18:51:18 UTC
This works now for all raw test images that I have available here.
It's pretty difficult to get it all right...

Note: I cannot confirm the problem of #0, JPEGs are rotated correctly here.
Comment 12 Roman Fietze 2007-07-02 19:33:20 UTC
The JPEGs are of course rotated. This was a fatal bug in module brain of unit Roman. :)

I will check the digikam updates as soon as I have time and will close it if CR2s are rotated.
Comment 13 Arnd Baecker 2007-09-01 01:42:55 UTC
Roman, could you give an update on this bug, 
does it still persist with current svn?

Many thanks in advance, Arnd
Comment 14 Arnd Baecker 2007-09-24 22:39:54 UTC
Roman, could you give an update on this bug,
it would be nice if we could close this bug before 0.9.3.
is released.

Many thanks in advance, Arnd
Comment 15 Roman Fietze 2007-09-24 23:02:02 UTC
Sorry for the delay, but we had been "off shore" during the last school holidays.

I have the problem that I normally do not keep the SVN version of KDE on my system, compiling all the libs and e.g. digikam just takes too long on my old 2x500, so I currently just use the OpenSUSE 10.2 repositories.

I will try to compile KDE+digikam on my companies box at night time. 0.9.3 is planned for september, maybe I can do it.

Another solution would be to send you (or attach) a landscape Canon CR2 so you can test that on your system.
Comment 16 Roman Fietze 2007-09-24 23:03:36 UTC
I wrote

> Another solution would be to send you (or attach) a landscape ...

I meant portrait of course, landscape isn't a problem at all.
Comment 17 Arnd Baecker 2007-09-24 23:08:07 UTC
just a remark:

you don't have to compile KDE itself, just the relevant libs
as described on the homepage.
Comment 18 Roman Fietze 2007-09-27 23:23:48 UTC
Due to problems compiling just the digikam libs I took the following approach:

- digikam SUSE SRPMs: digikam-0.9.2-29.4 for OpenSUSE 10.2
- create RPMs with your two modifications in threadimageio
- install RPMs

And it works, the CR2 previews are rotated
Comment 19 Arnd Baecker 2007-09-27 23:57:17 UTC
great - thanks a lot for the feed-back!