[Digikam-devel] [Bug 132694] RAW Thumbnailing very slower and resource intensive

Gilles Caulier caulier.gilles at free.fr
Wed Sep 6 15:11:24 CEST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=132694         




------- Additional Comments From caulier.gilles free fr  2006-09-06 15:10 -------
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)


More information about the Digikam-devel mailing list