Bug 141877 - No thumbnails for RAW files (Epson R-D1, supported in dcraw)
Summary: No thumbnails for RAW files (Epson R-D1, supported in dcraw)
Status: RESOLVED FIXED
Alias: None
Product: kphotoalbum
Classification: Applications
Component: Backend (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KPhotoAlbum Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-18 19:10 UTC by Cesar Crusius
Modified: 2007-08-18 15:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
ImageManager-recognize-erf.patch (571 bytes, patch)
2007-05-11 04:02 UTC, Jan Kundrát
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cesar Crusius 2007-02-18 19:10:22 UTC
Version:           3.0 (using KDE 3.5.5, Gentoo)
Compiler:          Target: i686-pc-linux-gnu
OS:                Linux (i686) release 2.6.19-gentoo-r5

KPhotoAlbum does not recognize the .erf files generated by the Epson R-D1. The files are not listed (and of course there are no thumbnails). My camera is set up so that no previews are stored in the file (for space savings), but that should be fine since dcraw deals with these files just fine.
Comment 1 Shawn Willden 2007-05-10 15:12:52 UTC
Can you provide a sample image file or two?
Comment 2 Cesar Crusius 2007-05-10 22:22:45 UTC
The files are too big for creating an attachment to the bug (~9M). Anywhere else I can put them?
Comment 3 Jan Kundrát 2007-05-10 23:28:15 UTC
You can try to use any service listed at http://www.rapget.com/en/ . When you upload the file, please mail the URL to me (jkt@gentoo.org) and I'll post the files somewhere where people can easily download them.
Comment 4 Jan Kundrát 2007-05-11 04:00:14 UTC
File is available at http://dev.gentoo.org/~jkt/tmp/kde-bug-141877-digital00092-eps2029.erf and KPA indeed doesn't recognize it.
Comment 5 Jan Kundrát 2007-05-11 04:02:46 UTC
Created attachment 20533 [details]
ImageManager-recognize-erf.patch

Trivial patch that allows KPA to at least *see* the file. It still loads only a
thumbnail from it for me, but that's a separate problem.
Comment 6 Jan Kundrát 2007-05-19 01:02:36 UTC
SVN commit 666157 by jkt:

CCBUG: 141877
Recognize Epson R-D1 RAW format (.erf). Still no real support for it besides viewing thumbnails, though...


 M  +1 -0      RawImageDecoder.cpp  


--- trunk/extragear/graphics/kphotoalbum/ImageManager/RawImageDecoder.cpp #666156:666157
@@ -70,6 +70,7 @@
 										  QString::fromLatin1("raf"),
 										  QString::fromLatin1("rdc"),
 										  QString::fromLatin1("x3f"),
+										  QString::fromLatin1("erf"),
 										  QString::null };
 	if (Settings::SettingsData::instance()->dontReadRawFilesWithOtherMatchingFile()) {
             static const QString standardExtensions[] = {
Comment 7 Jan Kundrát 2007-08-18 05:16:24 UTC
SVN commit 701359 by jkt:

FEATURE: Use libkdcraw for RAW image processing instead of a bundled and
outdated dcraw copy.

Epson R-D1 RAW format (.erf) should be supported better...

BUG: 130781
CCBUG: 141877
BUG: 145941


 M  +4 -0      ChangeLog  
 M  +8 -3      ImageManager/ImageLoader.cpp  
 M  +1 -2      ImageManager/Makefile.am  
 M  +9 -22     ImageManager/RawImageDecoder.cpp  
 D             ImageManager/parse.c  
 M  +1 -1      Makefile.am  
 M  +17 -0     configure.in.in  


--- branches/extragear/kde3/graphics/kphotoalbum/ChangeLog #701358:701359
@@ -1,3 +1,7 @@
+2007-08-18  Jan Kundrat  <jkt@gentoo.org>
+
+	* Use libkdcraw intead of budled and rotten dcraw copy
+
 2007-08-11  Jan Kundrat  <jkt@gentoo.org>
 
 	* Automatically hide mouse cursor and disable screensaver when in Viewer
--- branches/extragear/kde3/graphics/kphotoalbum/ImageManager/ImageLoader.cpp #701358:701359
@@ -137,15 +137,20 @@
     }
 
     else {
-        ok = img.load( request->fileName() );
+        // At first, we have to give our RAW decoders a try. If we allowed
+        // QImage's load() method, it'd for example load a tiny thumbnail from
+        // NEF files, which is not what we want.
+        ok = ImageDecoder::decode( &img, request->fileName(),  &fullSize, dim);
         if (ok)
             request->setFullSize( img.size() );
     }
+
     if (!ok) {
-        // Still didn't work, try with our own decoders
-        ok = ImageDecoder::decode( &img, request->fileName(),  &fullSize, dim);
+        // Now we can try QImage's stuff as a fallback...
+        ok = img.load( request->fileName() );
         if (ok)
             request->setFullSize( img.size() );
+
     }
 
     return img;
--- branches/extragear/kde3/graphics/kphotoalbum/ImageManager/Makefile.am #701358:701359
@@ -3,8 +3,7 @@
 INCLUDES = -I$(srcdir)/.. $(all_includes)
 
 libImageManager_la_SOURCES = ImageLoader.cpp Manager.cpp ImageRequest.cpp ImageClient.cpp \
-			     ImageDecoder.cpp RawImageDecoder.cpp parse.c VideoManager.cpp \
-			     RequestQueue.cpp
+			     ImageDecoder.cpp RawImageDecoder.cpp VideoManager.cpp RequestQueue.cpp
 
 
 KDE_CXXFLAGS = $(USE_EXCEPTIONS) $(USE_THREADS) -DQT_NO_CAST_ASCII -DQT_CAST_NO_ASCII
--- branches/extragear/kde3/graphics/kphotoalbum/ImageManager/RawImageDecoder.cpp #701358:701359
@@ -23,36 +23,23 @@
 #include <qwmatrix.h>
 #include <qstringlist.h>
 #include "Settings/SettingsData.h"
+#include <libkdcraw/kdcraw.h>
 
-/* Main entry point into raw parser */
-extern "C" {
-	int extract_thumbnail( FILE*, FILE*, int* );
-}
-
 namespace ImageManager
 {
 
 bool RAWImageDecoder::_decode( QImage *img, const QString& imageFile, QSize* fullSize, int dim)
 {
-  /* width and height seem to be only hints, ignore */
-  Q_UNUSED( dim );
-  /* Open file and extract thumbnail */
-  FILE* input = fopen( QFile::encodeName(imageFile), "rb" );
-  if( !input ) return false;
-  KTempFile output;
-  output.setAutoDelete(true);
-  int orientation = 0;
-  if( extract_thumbnail( input, output.fstream(), &orientation ) ) {
-	fclose(input);
-	return false;
-  }
-  fclose(input);
-  output.close();
-  if( !img->load( output.name() ) ) return false;
+    /* width and height seem to be only hints, ignore */
+    Q_UNUSED( dim );
 
-  if( fullSize ) *fullSize = img->size();
+    if ( !KDcrawIface::KDcraw::loadDcrawPreview( *img, imageFile ) )
+        return false;
 
-  return true;
+    if ( fullSize )
+        *fullSize = img->size();
+
+    return true;
 }
 
 QStringList RAWImageDecoder::_rawExtensions;
--- branches/extragear/kde3/graphics/kphotoalbum/Makefile.am #701358:701359
@@ -34,7 +34,7 @@
 		     CategoryListView/libCategoryListView.la \
                      $(LIBKPHOTOALBUM_SQLDB) $(LIB_KIO) -ljpeg $(KPHOTOALBUM_KIPI_LIBS) $(KPHOTOALBUM_KEXI_LIBS) \
                      $(LIBKPHOTOALBUM_KEXIDB) HTMLGenerator/libHTMLGenerator.la\
-	             $(KPHOTOALBUM_EXIV2_LIBS) -lkmediaplayer
+	             $(KPHOTOALBUM_EXIV2_LIBS) -lkmediaplayer -lkdcraw
 
 METASOURCES = AUTO
 KDE_CXXFLAGS = $(USE_EXCEPTIONS) $(USE_THREADS) -DQT_NO_CAST_ASCII -DQT_CAST_NO_ASCII 
--- branches/extragear/kde3/graphics/kphotoalbum/configure.in.in #701358:701359
@@ -75,7 +75,24 @@
 fi
 
 
+# -------------------------------------------------- kdcraw Check
+if test "$PKGCONFIGFOUND" = "yes" ; then
+   have_libkdcraw=no
 
+   KDE_PKG_CHECK_MODULES(LIBKDCRAW, libkdcraw >= 0.1.1,
+                         have_libkdcraw=yes, have_libkdcraw=no)
+
+   if test "x$have_libkdcraw" = "xno"; then
+       AC_MSG_RESULT([no])
+       AC_MSG_ERROR([Can't find the libkdcraw library]);
+   else
+       AC_MSG_RESULT([yes])
+   fi
+else
+   AC_MSG_ERROR([Can't find the libkdcraw library]);
+fi 
+
+
 # -------------------------------------------------- KexiDB Check
 #KDE_CHECK_HEADER(kexidb/connection.h, have_kexidb=yes, have_kexidb=no)
 
Comment 8 Jan Kundrát 2007-08-18 15:04:27 UTC
SVN commit 701490 by jkt:

Decode RAW data if the embedded thumbnail's dimensions are less than 80% of the real image size

BUG: 141877


 M  +35 -0     RawImageDecoder.cpp  


--- branches/extragear/kde3/graphics/kphotoalbum/ImageManager/RawImageDecoder.cpp #701489:701490
@@ -24,6 +24,7 @@
 #include <qstringlist.h>
 #include "Settings/SettingsData.h"
 #include <libkdcraw/kdcraw.h>
+#include <kdebug.h>
 
 namespace ImageManager
 {
@@ -36,6 +37,40 @@
     if ( !KDcrawIface::KDcraw::loadDcrawPreview( *img, imageFile ) )
         return false;
 
+    KDcrawIface::DcrawInfoContainer metadata;
+
+    if ( !KDcrawIface::KDcraw::rawFileIdentify( metadata, imageFile ) ||
+            ( img->width() < metadata.imageSize.width() * 0.8 ) ||
+            ( img->height() < metadata.imageSize.height() * 0.8 ) ) {
+
+        // let's try to get a better resolution
+        KDcrawIface::KDcraw decoder;
+        KDcrawIface::RawDecodingSettings rawDecodingSettings;
+
+        if ( rawDecodingSettings.sixteenBitsImage ) {
+            kdDebug() << "16 bits per color channel is not supported yet" << endl;
+            return false;
+        } else {
+            QByteArray imageData; /* 3 bytes for each pixel,  */
+            int width, height, rgbmax;
+            if ( !decoder.decodeRAWImage( imageFile, rawDecodingSettings, imageData, width, height, rgbmax ) )
+                return false;
+
+            // Now the funny part, how to turn this fugly QByteArray into an QImage. Yay!
+            if ( !img->create( width, height, 32 ) )
+                return false;
+
+            uchar* data = img->bits();
+
+            for ( uint i = 0; i < imageData.size(); i += 3, data += 4 ) {
+                data[0] = imageData[i + 2]; // blue
+                data[1] = imageData[i + 1]; // green
+                data[2] = imageData[i];     // red
+                data[3] = 0xff;             // alpha
+            }
+        }
+    }
+
     if ( fullSize )
         *fullSize = img->size();