Bug 90875 - preview of RAW-Files in album
Summary: preview of RAW-Files in album
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Preview-RAW (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-06 19:49 UTC by Thorsten Schnebeck
Modified: 2019-12-23 17:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thorsten Schnebeck 2004-10-06 19:49:56 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

Hi,

a simple wish :-) It would be nice to have a preview of RAW files. RAW files are normally processed by dcraw. Some of these RAW files have an embedded thumbnail images, which could be used for a fast preview. On the homepage of dcraw you can find the program parse.c.
http://www.cybercom.net/~dcoffin/dcraw/parse.c

This program can be used to extract the embedded thumbnail.
Oh, for Canons CRW Format this embedded jpg is quite large, ~1500x1000 pixel.

Maybe this wish can be achieved on kimgio-level, so every KDE app gets the preview(?)

Bye

  Thorsten
Comment 1 Unai Garro 2004-12-28 20:57:53 UTC
*** This bug has been confirmed by popular vote. ***
Comment 2 Renchi Raju 2004-12-29 00:07:12 UTC
CVS commit by pahlibar: 


Use dcraw to generate a quick-image to generate thumbnails for raw images. Its
more reliable than using Dave Coffin's parse.c in extracting images and the 
generation speed seems reasonable

BUG: 90875


  M +102 -43   digikamthumbnail.cpp   1.13 [POSSIBLY UNSAFE: popen]
  M +3 -2      digikamthumbnail.h   1.4


--- kdeextragear-3/digikam/kioslave/digikamthumbnail.cpp  #1.12:1.13
@@ -52,7 +52,8 @@ extern "C" 
 {
 #include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 #include <jpeglib.h>
-#include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -330,5 +331,9 @@ void kio_digikamthumbnailProtocol::get(c
             {
                 // Try to load with QT/KDELib API...
-                img.load(url.path());            
+                if (!img.load(url.path()))
+                {
+                    // Try to load with dcraw
+                    loadDCRAW( img, url.path() );
+                }
             }
         }
@@ -557,4 +562,58 @@ bool kio_digikamthumbnailProtocol::loadI
 }
 
+bool kio_digikamthumbnailProtocol::loadDCRAW(QImage& image, const QString& path)
+{
+    QCString command;
+
+    // run dcraw with options:
+    // -c : write to stdout
+    // -h : Half-size color image (3x faster than -q)
+    // -2 : 8bit ppm output
+    // -a : Use automatic white balance
+    // -w : Use camera white balance, if possible
+    command  = "dcraw -c -h -2 -w -a ";
+    command += "'";
+    command += QFile::encodeName( path );
+    command += "'";
+    kdDebug() << "Running dcraw command " << command << endl;
+
+    FILE* f = popen( command.data(), "r" );
+
+    QByteArray imgData;
+
+    if ( !f )
+        return false;
+
+    const int MAX_IPC_SIZE = (1024*32);
+    char buffer[MAX_IPC_SIZE];
+
+    QFile file;
+    file.open( IO_ReadOnly,  f );
+    Q_LONG len;
+    while ((len = file.readBlock(buffer, MAX_IPC_SIZE)) != 0)
+    {
+        if ( len == -1 )
+        {
+            file.close();
+            return false;
+        }
+        else
+        {
+            int oldSize = imgData.size();
+            imgData.resize( imgData.size() + len );
+            memcpy(imgData.data()+oldSize, buffer, len);
+        }
+    }
+
+    file.close();
+    pclose( f );
+
+    if ( imgData.isEmpty() )
+        return false;
+
+    image.loadFromData( imgData );
+    return true;
+}
+
 void kio_digikamthumbnailProtocol::createThumbnailDirs()
 {

--- kdeextragear-3/digikam/kioslave/digikamthumbnail.h  #1.3:1.4
@@ -47,4 +47,5 @@ private:
     bool loadJPEG(QImage& image, const QString& path);
     bool loadImlib2(QImage& image, const QString& path);
+    bool loadDCRAW(QImage& image,  const QString& path);
     void createThumbnailDirs();
     


Comment 3 caulier.gilles 2019-12-23 17:31:17 UTC
Not reproducible with digiKam 7.0.0-beta1.