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
*** This bug has been confirmed by popular vote. ***
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();
Not reproducible with digiKam 7.0.0-beta1.