Bug 130781 - kphotoalbum cannot read NEF raw files when TIFF support is enabled
Summary: kphotoalbum cannot read NEF raw files when TIFF support is enabled
Status: RESOLVED FIXED
Alias: None
Product: kphotoalbum
Classification: Applications
Component: Backend (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KPhotoAlbum Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-13 19:28 UTC by Deathwing00
Modified: 2007-08-18 05:16 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Deathwing00 2006-07-13 19:28:41 UTC
Version:           2.2 (using KDE KDE 3.5.3)
Installed from:    Gentoo Packages
Compiler:          gcc-4.1.1, glibc-2.4-r3, 2.6.16-gentoo-r9 i686 
OS:                Linux

Some users have confirmed the following behaviour:

When TIFF support is enabled at kdelibs and kphotoalbum
- All TIFF files are handled correctly, however NEF files will not be loaded. Only the thumbnail of them can be seen.

When TIFF support is disabled:
- Only non-lwz-compressed TIFF files can be handled; on the other hand, NEF files are treated correctly.

I was not able to solve the problem locally, so I guess it might be an internal application bug.
For additional details, see https://bugs.gentoo.org/show_bug.cgi?id=139775
Comment 1 Jan Kundrát 2007-05-11 02:06:22 UTC
The original reporter was kind enough to send a sample to me. It's available at http://dev.gentoo.org/~jkt/tmp/gentoo-bug-139775-DSC_2830.NEF .
Comment 2 Risto H. Kurppa 2007-05-17 00:53:42 UTC
Hey - I've been using KPA for almost 2 years and this is the first time I hear it'd be possible to actually see NEF's as proper images, not only messy, small resolution thumbnails. Please, someone, fix this! (though I'm happy to give up the TIFF support if I only get NEF's work ok..)
Comment 3 Tuomas Suutari 2007-05-17 01:04:32 UTC
Seems that showFoto (the digiKam photo viewer/editor) also shows only the small thumbnail. Maybe this is a problem in kdelibs that cannot be fixed by KPhotoAlbum?
Comment 4 Tuomas Suutari 2007-05-17 01:21:38 UTC
Correction: showFoto shows only the thumbnail when that file is opened directly from the web, but when opened from local filesystem it shows the real data. So it's possible to fix this in KPhotoAlbum too.
Comment 5 Risto H. Kurppa 2007-05-17 02:29:56 UTC
Are these connected: http://bugs.kde.org/show_bug.cgi?id=126881
Comment 6 Risto H. Kurppa 2007-05-24 23:13:44 UTC
I updated to KDE 3.5.7 and magic - I can see NEF thumbmnails and also the image viewer shows the image w. proper resolution.

Some issues still: image size is shown as 160x120 (0.0MP) but the real resolution (as EXIF shows) is 2014x3040.

And if I press Enter to show the image full screen, it also zooms a lot and messes  the view. Enter again, the window title shows zoom of x18.9 that changes to Zoom x400 (so I suppose the full screen zoom factor is 18.9 and then it changes to 400) . Press Enter twice, it shows Zoom xinf..

So Enter seems to activate the zoom as well.. After this the zoom keyboard shortcuts also fail to work correctly.
Comment 7 nallebrean 2007-05-25 01:18:49 UTC
Dose that work fore the sample image in here too? I tryed to upgrade to kde 3.5.7 but no differens and all my nef/raw files are in the same format.
Comment 8 Risto H. Kurppa 2007-05-25 10:35:50 UTC
I don't know what has happened - I installed some new video editors (cinelerra, pitivi, kdenlive) and started KPA this morning and bang - it doesn't work any more. Images are back to 160pix resolution. I'd really respect if someone was able to find the reason for this unstable behavior.. 
Comment 9 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)