Bug 132694 - RAW Thumbnailing very slower and resource intensive
Summary: RAW Thumbnailing very slower and resource intensive
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Thumbs-RAW (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-20 17:33 UTC by Hubert Figuiere
Modified: 2017-07-27 10:56 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.9.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hubert Figuiere 2006-08-20 17:33:55 UTC
Version:           0.9-beta1 (using KDE KDE 3.5.4)
Installed from:    Ubuntu Packages

At the moment thumbnailing use dcraw, which very slow and resource intensive. Extracting the preview should be the way to go. Hint: dcparse
Comment 1 caulier.gilles 2006-08-20 21:08:29 UTC
Witch dcraw version you use ? I suspect that you have a dcraw < 8.x intalled in your computer !

digiKam use now the new dcraw "-e" option to extract Raw preview image. The code to extract the preview image from the new implementation of dcraw::parse.c have been removed. This code have been migrated in dcraw.c since 8.x release.

To have performed some tests between the old dcraw:parse method include in digiKam (but not used now) and the new dcraw -e option, the time to extract the RAW preview image is the same.

In your case, if you have a dcraw verion < 8.x, digiKam will failed to use the -e option and it will use a slow alternative method using another dcraw options.

Gilles Caulier
Comment 2 caulier.gilles 2006-08-24 09:33:31 UTC
Hubert, have you updated your dcraw version in your computer (:=))??? 

Gilles
Comment 3 Hubert Figuiere 2006-08-24 17:43:49 UTC
it is faster now.

I have updated dcraw in Ubuntu Edgy at the same time.
Comment 4 caulier.gilles 2006-08-24 18:36:25 UTC
Ok. Thanks. I close this file now.

Gilles
Comment 5 caulier.gilles 2006-09-06 15:08:12 UTC
SVN commit 581470 by cgilles:

digikam from trunk : dcraw autodetection at startup : now digiKAm check the dcraw version installed on your computer and report the results to user if necessary.

This commit fix showfoto RAW files rules if dcraw detection has failed.

Note : 
- minimum dcraw version require : 8.09.
- recommended dcraw version >= 8.30.

CCBUGS: 132694

 M  +1 -1      albumiconview.cpp  
 M  +30 -11    digikamapp.cpp  
 M  +0 -1      digikamapp.h  
 M  +0 -4      main.cpp  


--- trunk/extragear/graphics/digikam/digikam/albumiconview.cpp #581469:581470
@@ -890,7 +890,7 @@
     QString imagefilter = settings->getImageFileFilter().lower() +
                           settings->getImageFileFilter().upper();
 
-    if (DcrawBinary::instance()->isAvailable())
+    if (DcrawBinary::instance()->versionIsRight())
     {
         // add raw files only if dcraw is available
         imagefilter += settings->getRawFileFilter().lower() +
--- trunk/extragear/graphics/digikam/digikam/digikamapp.cpp #581469:581470
@@ -35,6 +35,7 @@
 
 // KDE includes.
 
+#include <kaboutdata.h>
 #include <kconfig.h>
 #include <kdebug.h>
 #include <klocale.h>
@@ -101,13 +102,12 @@
 DigikamApp::DigikamApp()
           : KMainWindow( 0, "Digikam" )
 {
-    m_instance     = this;
-    m_config       = kapp->config();
-    m_accelerators = 0;
-
-    mFullScreen   = false;
-    mView         = 0;
-    mValidIccPath = true;
+    m_instance        = this;
+    m_config          = kapp->config();
+    m_accelerators    = 0;
+    mFullScreen       = false;
+    mView             = 0;
+    mValidIccPath     = true;
     
     mSplash = 0;
     if(m_config->readBoolEntry("Show Splash", true) &&
@@ -123,9 +123,10 @@
     AlbumLister::instance();
 
     mCameraMediaList = new QPopupMenu;
-    connect( mCameraMediaList, SIGNAL( aboutToShow() ),
-             SLOT( slotCameraMediaMenu() ) );
 
+    connect(mCameraMediaList, SIGNAL( aboutToShow() ),
+            this, SLOT(slotCameraMediaMenu()));
+
     mCameraList = new CameraList(this, locateLocal("appdata", "cameras.xml"));
 
     connect(mCameraList, SIGNAL(signalCameraAdded(CameraType *)),
@@ -140,22 +141,32 @@
 
     applyMainWindowSettings(m_config);
 
+    // Check ICC profiles repository
+    if(mSplash)
+        mSplash->message(i18n("Checking ICC repository"), AlignLeft, white);
+
     m_config->setGroup("Color Management");
     QDir tmpPath(m_config->readPathEntry("DefaultPath", QString::null));
     if (!tmpPath.exists())
     {
         mValidIccPath = false;
     }
-
     kdDebug() << "ICC profiles repository is: " << tmpPath.dirName() << endl;
 
+    // Check witch dcraw version available
+
+    if(mSplash)
+        mSplash->message(i18n("Checking dcraw version"), AlignLeft, white);
+
+    Digikam::DcrawBinary::instance()->checkSystem();
+
     // Actual file scanning is done in main() - is this necessary here?
     mAlbumManager->setLibraryPath(mAlbumSettings->getAlbumLibraryPath());
 
+    // Read albums from database
     if(mSplash)
         mSplash->message(i18n("Reading database"), AlignLeft, white);
 
-    // Read albums from database
     mAlbumManager->startScan();
 
     // Load KIPI Plugins.
@@ -167,8 +178,10 @@
     setAutoSaveSettings();
 
     mDcopIface = new DCOPIface(this, "camera");
+
     connect(mDcopIface, SIGNAL(signalCameraAutoDetect()), 
             this, SLOT(slotDcopCameraAutoDetect()));
+
     connect(mDcopIface, SIGNAL(signalDownloadImages( const QString & )),
             this, SLOT(slotDcopDownloadImages(const QString &)));
 }
@@ -205,6 +218,7 @@
 
 void DigikamApp::show()
 {
+    // Remove Splashscreen.
     if(mSplash)
     {
         mSplash->finish(this);
@@ -213,6 +227,8 @@
     }
 
     KMainWindow::show();
+
+    // Report errors from ICC repository path.
     if(!mValidIccPath)
     {
         QString message = i18n("<qt><p>ICC profiles path seems to be invalid.</p>"
@@ -232,6 +248,9 @@
             m_config->writeEntry("EnableCM", false);
         }
     }
+
+    // Report errors from dcraw detection.
+    Digikam::DcrawBinary::instance()->checkReport();  
 }
 
 const QPtrList<KAction>& DigikamApp::menuImageActions()
--- trunk/extragear/graphics/digikam/digikam/digikamapp.h #581469:581470
@@ -163,7 +163,6 @@
 private:
 
     bool                   mFullScreen;
-
     bool                   mValidIccPath;
     
     // KIPI plugins support
--- trunk/extragear/graphics/digikam/digikam/main.cpp #581469:581470
@@ -53,7 +53,6 @@
 #include "albummanager.h"
 #include "digikamapp.h"
 #include "digikamfirstrun.h"
-#include "dcrawbinary.h"
 
 static KCmdLineOptions options[] =
 {
@@ -236,9 +235,6 @@
         return app.exec();
     }
 
-    if (!Digikam::DcrawBinary::instance()->checkSystem())
-        return 1;
-
     Digikam::AlbumManager* man = new Digikam::AlbumManager();
     man->setLibraryPath(albumPath);
 
Comment 6 caulier.gilles 2006-09-06 15:10:17 UTC
SVN commit 581473 by cgilles:

digikam from trunk : dcraw autodetection at startup : now digiKAm check the dcraw version installed on your computer and report the results to user if necessary.

This commit fix showfoto RAW files rules if dcraw detection has failed.

Note : 
- minimum dcraw version require : 8.09.
- recommended dcraw version >= 8.30.

CCBUGS: 132694

 M  +11 -10    digikam.kdevelop  
 M  +9 -0      libs/dcraw/Makefile.am  
 M  +113 -39   libs/dcraw/dcrawbinary.cpp  
 M  +23 -7     libs/dcraw/dcrawbinary.h  
 M  +0 -5      showfoto/main.cpp  
 M  +24 -4     showfoto/showfoto.cpp  


--- trunk/extragear/graphics/digikam/digikam.kdevelop #581472:581473
@@ -12,7 +12,7 @@
     </keywords>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description/>
+    <description></description>
     <ignoreparts/>
     <versioncontrol>kdevsubversion</versioncontrol>
   </general>
@@ -73,11 +73,11 @@
   <kdevdebugger>
     <general>
       <dbgshell>libtool</dbgshell>
-      <programargs/>
-      <gdbpath/>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <programargs></programargs>
+      <gdbpath></gdbpath>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
@@ -89,6 +89,7 @@
     </display>
   </kdevdebugger>
   <kdevfilecreate>
+    <filetypes/>
     <useglobaltypes>
       <type ext="ui" />
       <type ext="cpp" />
@@ -109,10 +110,10 @@
       <prio>0</prio>
     </make>
     <run>
-      <directoryradio>executable</directoryradio>
+      <directoryradio>build</directoryradio>
       <customdirectory>/</customdirectory>
-      <mainprogram>digikam/digikam/digikam</mainprogram>
-      <programargs/>
+      <mainprogram>digikam/showfoto/showfoto</mainprogram>
+      <programargs></programargs>
       <terminal>false</terminal>
       <autocompile>false</autocompile>
       <envvars/>
@@ -165,7 +166,7 @@
       <headerCompletionDelay>250</headerCompletionDelay>
     </codecompletion>
     <creategettersetter>
-      <prefixGet/>
+      <prefixGet></prefixGet>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
--- trunk/extragear/graphics/digikam/libs/dcraw/Makefile.am #581472:581473
@@ -7,3 +7,12 @@
 libdcraw_la_SOURCES = dcraw_parse.cpp dcrawbinary.cpp dcrawpreview.cpp
 
 libdcraw_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+# binary
+#bin_PROGRAMS = digikamdcraw
+
+#digikamdcraw_CFLAGS = -w
+
+#digikamdcraw_SOURCES = dcraw.c
+
+#digikamdcraw_LDFLAGS = -O4 -lm -ljpeg -lcms 
\ No newline at end of file
--- trunk/extragear/graphics/digikam/libs/dcraw/dcrawbinary.cpp #581472:581473
@@ -1,7 +1,7 @@
 /* ============================================================
  * Author: Marcel Wiesweg <marcel.wiesweg@gmx.de>
  * Date  : 2006-04-13
- * Description : Autodetect dcraw binary
+ * Description : Autodetect dcraw binary program and version
  *
  * Copyright 2006 by Marcel Wiesweg
  *
@@ -18,16 +18,15 @@
  *
  * ============================================================ */
 
-// Qt includes
-
-#include <qprocess.h>
-
 // KDE includes
 
+#include <kapplication.h>
+#include <kprocess.h>
 #include <kmessagebox.h>
 #include <kapplication.h>
 #include <klocale.h>
 #include <kglobal.h>
+#include <kdebug.h>
 #include <kaboutdata.h>
 
 // Local includes
@@ -37,16 +36,33 @@
 namespace Digikam
 {
 
+class DcrawBinaryPriv
+{
+public:
+
+    DcrawBinaryPriv()
+    {
+        available = false;
+        version   = QString::null;
+    }
+
+    bool    available;
+
+    QString version;
+};
+
 DcrawBinary *DcrawBinary::m_instance = 0;
 
 DcrawBinary::DcrawBinary()
+           : QObject()
 {
-    m_available = false;
+    d = new DcrawBinaryPriv;
 }
 
 DcrawBinary::~DcrawBinary()
 {
     m_instance = 0;
+    delete d;
 }
 
 DcrawBinary *DcrawBinary::instance()
@@ -61,44 +77,31 @@
     delete m_instance;
 }
 
-bool DcrawBinary::checkSystem()
+void DcrawBinary::checkSystem()
 {
-    QProcess process;
-
+    KProcess process;
     process.clearArguments();
-    process.addArgument("dcraw");
+    process << path();    
 
-    QString appName = KGlobal::instance()->aboutData()->programName();
+    connect(&process, SIGNAL(receivedStderr(KProcess *, char*, int)),
+            this, SLOT(slotReadStderrFromDcraw(KProcess*, char*, int)));
 
-    m_available = process.start();
+    d->available = process.start(KProcess::Block, KProcess::Stderr);
+}
 
-    if (!m_available) {
-        int ret = KMessageBox::warningContinueCancel(
-                           kapp->activeWindow(),
-                           i18n("<qt><p>Unable to find the dcraw executable:<br> "
-                                "This program is required by %1 to support raw file formats. "
-                                "You can run %2 without this, but you will not be able "
-                                "to view or edit any images in raw file formats. "
-                                "Please install dcraw as a package from your distributor "
-                                "or <a href=\"%3\">download the source</a>.</p>"
-                                "<p>Do you want to continue starting %4?</p></qt>")
-                                .arg(appName)
-				.arg(appName)
-                                .arg("http://www.cybercom.net/~dcoffin/dcraw/")
-				.arg(appName),
-                           QString::null,
-                           KStdGuiItem::cont(),
-                           QString::fromLatin1("dcrawdetection"),
-                           KMessageBox::Notify | KMessageBox::AllowLink
-                          );
+void DcrawBinary::slotReadStderrFromDcraw(KProcess*, char* buffer, int buflen)
+{
+    // The dcraw ouput look like this : Raw Photo Decoder "dcraw" v8.30...
+    QString dcrawHeader("Raw Photo Decoder \"dcraw\" v");
 
-        if (ret == KMessageBox::Cancel)
-            return false;
+    QString stdErr    = QString::fromLocal8Bit(buffer, buflen);
+    QString firstLine = stdErr.section('\n', 1, 1);    
+
+    if (firstLine.startsWith(dcrawHeader))
+    {
+        d->version = firstLine.remove(0, dcrawHeader.length());    
+        kdDebug() << "Found dcraw version: " << version() << endl;    
     }
-
-    // Veturn true even if m_available is false,
-    // return value indicates whether the user wants to abort or continue
-    return true;
 }
 
 const char *DcrawBinary::path()
@@ -106,10 +109,81 @@
     return "dcraw";
 }
 
-bool DcrawBinary::isAvailable()
+bool DcrawBinary::isAvailable() const
 {
-    return m_available;
+    return d->available;
 }
 
+QString DcrawBinary::version() const
+{
+    return d->version;
+}
+
+bool DcrawBinary::versionIsRight() const
+{
+    if (d->version.isNull() || !isAvailable())
+        return false;
+
+    if (d->version.toFloat() >= minimalVersion().toFloat())
+        return true;
+
+    return false;
+}
+
+QString DcrawBinary::minimalVersion() const
+{
+    return QString("8.09");
+}
+
+void DcrawBinary::checkReport()
+{
+    QString appName = KGlobal::instance()->aboutData()->programName();
+
+    if (!isAvailable()) 
+    {
+        KMessageBox::information(
+                     kapp->activeWindow(),
+                     i18n("<qt><p>Unable to find the dcraw executable:<br> "
+                          "This program is required by %1 to support raw file formats. "
+                          "You can use %2 without this, but you will not be able "
+                          "to view or edit any images in raw file formats. "
+                          "Please install dcraw as a package from your distributor "
+                          "or <a href=\"%3\">download the source</a>.</p>"
+                          "<p>Note: at least, dcraw version %4 is require by %5</p></qt>")
+                          .arg(appName)
+                          .arg(appName)
+                          .arg("http://www.cybercom.net/~dcoffin/dcraw")
+                          .arg(minimalVersion())
+                          .arg(appName),
+                     QString::null,
+                     QString::null,
+                     KMessageBox::Notify | KMessageBox::AllowLink);
+    }
+
+    if (!versionIsRight()) 
+    {
+        KMessageBox::information(
+                     kapp->activeWindow(),
+                     i18n("<qt><p>dcraw executable isn't up to date:<br> "
+                          "The version %1 of dcraw have been found on your computer. "
+                          "This version is too old to run properlly with %2. "
+                          "You can run %3 like this, but you will not be able "
+                          "to view or edit any images in raw file formats. "
+                          "Please update dcraw as a package from your distributor "
+                          "or <a href=\"%4\">download the source</a>.</p>"
+                          "<p>Note: at least, dcraw version %5 is require by %6</p></qt>")
+                          .arg(Digikam::DcrawBinary::instance()->version())
+                          .arg(appName)
+                          .arg(appName)
+                          .arg("http://www.cybercom.net/~dcoffin/dcraw")
+                          .arg(Digikam::DcrawBinary::instance()->minimalVersion())
+                          .arg(appName),
+                     QString::null,
+                     QString::null,
+                     KMessageBox::Notify | KMessageBox::AllowLink);
+    }
+}
+
 }  // namespace Digikam
 
+#include "dcrawbinary.moc"
--- trunk/extragear/graphics/digikam/libs/dcraw/dcrawbinary.h #581472:581473
@@ -1,7 +1,7 @@
 /* ============================================================
  * Author: Marcel Wiesweg <marcel.wiesweg@gmx.de>
  * Date  : 2006-04-13
- * Description : Autodetect dcraw binary
+ * Description : Autodetect dcraw binary program and version
  *
  * Copyright 2006 by Marcel Wiesweg
  *
@@ -24,35 +24,51 @@
 // Qt includes.
 
 #include <qstring.h>
+#include <qobject.h>
 
 // Digikam Includes.
 
 #include "digikam_export.h"
 
+class KProcess;
+
 namespace Digikam
 {
 
-class DIGIKAM_EXPORT DcrawBinary
+class DcrawBinaryPriv;
+
+class DIGIKAM_EXPORT DcrawBinary : public QObject
 {
+    Q_OBJECT
 
 public:
 
     static DcrawBinary *instance();
     static void cleanUp();
 
-    bool checkSystem();
-
     const char *path();
-    bool isAvailable();
+    bool isAvailable() const;
+    QString version() const;
+    bool versionIsRight() const;
+    QString minimalVersion() const;
 
+    void checkSystem();
+    void checkReport();
+
+private slots:
+
+    void slotReadStderrFromDcraw(KProcess*, char*, int);
+
 private:
 
     DcrawBinary();
     ~DcrawBinary();
 
+private:
+
+    DcrawBinaryPriv    *d;
+
     static DcrawBinary *m_instance;
-
-    bool m_available;
 };
 
 } // namespace Digikam
--- trunk/extragear/graphics/digikam/showfoto/main.cpp #581472:581473
@@ -1,5 +1,4 @@
 /* ============================================================
- * File  : main.cpp
  * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
  *         Gilles Caulier <caulier dot gilles at kdemail dot net>
  * Date  : 2004-11-22
@@ -37,7 +36,6 @@
 // Local includes.
 
 #include "showfoto.h"
-#include "dcrawbinary.h"
 
 static KCmdLineOptions options[] =
 {
@@ -101,9 +99,6 @@
     KApplication app;
     KImageIO::registerFormats();
 
-    if (!Digikam::DcrawBinary::instance()->checkSystem())
-        return 1;
-
     KURL::List urlList;
     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
     for(int i = 0; i < args->count(); i++)
--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #581472:581473
@@ -78,6 +78,7 @@
 #include "rawfiles.h"
 #include "canvas.h"
 #include "thumbbar.h"
+#include "dcrawbinary.h"
 #include "imagepropertiessidebar.h"
 #include "imageplugin.h"
 #include "imagepluginloader.h"
@@ -124,6 +125,13 @@
         m_splash = new Digikam::SplashScreen("showfoto-splash.png");
     }
 
+    // Check witch dcraw version available
+
+    if(m_splash)
+        m_splash->message(i18n("Checking dcraw version"), AlignLeft, white);
+
+    Digikam::DcrawBinary::instance()->checkSystem();
+
     // -- Build the GUI -----------------------------------
 
     setupUserArea();
@@ -408,6 +416,9 @@
 #if KDE_IS_VERSION(3,5,2)
     //-- With KDE version >= 3.5.2, "image/x-raw" type mime exist ------------------------------
     
+    // TODO: - Remove all image/x-raw file format given by KDE and check if dcraw is available.
+    //       - Use the Raw file extension giving by digiKam API instead, because the list given 
+    //         by KDE is uncomplete.
     fileformats = KImageIO::mimeTypes(KImageIO::Reading).join(" ");
 #else
     //-- with KDE version < 3.5.2, we need to add all camera RAW file formats ------------------
@@ -418,14 +429,20 @@
     QString allPictures = patternList[0];
     
     // Add RAW file format to All Pictures" type mime and remplace current.
-    allPictures.insert(allPictures.find("|"), QString(raw_file_extentions));
-    patternList.remove(patternList[0]);
-    patternList.prepend(allPictures);
+    if (Digikam::DcrawBinary::instance()->versionIsRight())
+    {
+        allPictures.insert(allPictures.find("|"), QString(raw_file_extentions));
+        patternList.remove(patternList[0]);
+        patternList.prepend(allPictures);
+    }
     
     // Added RAW file formats supported by dcraw program like a type mime. 
     // Nota: we cannot use here "image/x-raw" type mime from KDE because it 
     // will be only available for KDE 3.5.2, not before (see file #121242 in B.K.O).
-    patternList.append(QString("\n%1|Camera RAW files").arg(QString(raw_file_extentions)));
+    if (Digikam::DcrawBinary::instance()->versionIsRight())
+    {
+        patternList.append(QString("\n%1|Camera RAW files").arg(QString(raw_file_extentions)));
+    }
     
     fileformats = patternList.join("\n");
 #endif
@@ -606,6 +623,9 @@
         m_splash = 0;
     }
     KMainWindow::show();
+
+    // Report errors from dcraw detection.
+    Digikam::DcrawBinary::instance()->checkReport();  
 }
 
 void ShowFoto::setup(bool iccSetupPage)