Bug 95871

Summary: Create Calendar cannot use 4 MPixel Image
Product: [Applications] digikam Reporter: Giovanni Venturi <giovanni>
Component: Plugin-Generic-CalendarAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 7.6.0

Description Giovanni Venturi 2004-12-27 16:20:43 UTC
Version:           0.1.0 (using KDE 3.3.2, compiled sources)
Compiler:          gcc version 3.3.4
OS:                Linux (i686) release 2.6.10

I get photo from my Canon PowerShot A80 with Digikam. Now I want to create a caledar with those photos, but I cannot use it. Create Calendar from Digikam plugins cannot use photo bigger that 1 MBytes.
Comment 1 Renchi Raju 2004-12-27 23:06:39 UTC
what do you mean by you can't use photos (bigger than 1MB). i just tried out a 15MB photo and i was able to reach upto the print preview page (i don't have a photo printer and so can't test if it actually prints, but its able to send the generated print page to the kde print system correctly and i would be surprised if it can't print that page).
Comment 2 Giovanni Venturi 2004-12-28 13:15:21 UTC
> tried out a 15MB photo and i was able to reach upto the print preview page
> (i don't have a photo printer and so can't test if it actually prints, but
> its able to send the generated print page to the kde print system correctly
> and i would be surprised if it can't print that page).
Well I cannot. I can't see the preview if the image is bigger thant 1 MBytes 
and when I insert it into a month hoping it's going to insert it also if I 
cannot see it than I get this message: "No valid images selected for months
Click Back to select images".
What verison on kipiplugins are you using? I've got:

digikam 0.7.1beta2
digikamplugins 0.7.1beta2
kipi-plugins-0.1beta1
libkexif-0.2.1
libkipi-0.1

not taken from CVS. Do you need some screenshot to confirm this bug?

Comment 3 Renchi Raju 2004-12-28 20:36:43 UTC
CVS commit by pahlibar: 


* the selection for the month url was being done only if a thumbnail could be
generated. if the image size happens to be larger than the user setting for
the preview data, the url was not being selected (as the thumbnail fails to 
generate). Fixed.
* Also use a generic image icon for the selected url till the thumbnail is
generated
BUG: 95871


  M +1 -1      calsettings.h   1.5
  M +68 -19    monthwidget.cpp   1.12
  M +1 -1      monthwidget.h   1.6


--- kdeextragear-libs-1/kipi-plugins/calendar/monthwidget.cpp  #1.11:1.12
@@ -28,4 +28,5 @@
 #include <qdragobject.h>
 #include <qstrlist.h>
+#include <qimage.h>
 
 // KDE includes.
@@ -38,4 +39,7 @@
 #include <klocale.h>
 #include <kglobal.h>
+#include <kapplication.h>
+#include <kiconloader.h>
+#include <kdebug.h>
 #include <kio/previewjob.h>
 
@@ -99,18 +103,43 @@ void MonthWidget::dropEvent(QDropEvent* 
 {
     KURL::List srcURLs;
-    KURLDrag::decode(event, srcURLs);
+    if ( !KURLDrag::decode(event, srcURLs) )
+        return;
+
+    if ( srcURLs.isEmpty() )
+        return;
+
+    KURL url = srcURLs.first();
+
+    // check if the file is an image
+    if ( QImageIO::imageFormat( url.path() ) )
+    {
+        imagePath_ = url;
+        CalSettings::instance()->setImage(month_, imagePath_);
+
+        KIconLoader* iconLoader = KApplication::kApplication()->iconLoader();
+        QPixmap pix = iconLoader->loadIcon("image", KIcon::NoGroup, 64 );
+        if ( pixmap_ )
+            delete pixmap_;
+        pixmap_ = new QPixmap( pix );
+        update();
+
+        KURL::List urls;
+        urls << url;
 
     KIO::PreviewJob* thumbJob_ =
-        KIO::filePreview( srcURLs,64);
+            KIO::filePreview( urls,64);
     connect(thumbJob_, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)),
             SLOT(slotGotThumbnaiL(const KFileItem*, const QPixmap&)));
+    }
+    else
+    {
+        kdWarning( 51001 ) << "Unknown image format for: "
+                           << url.prettyURL() << endl;
+    }
 }
 
-void MonthWidget::slotGotThumbnaiL(const KFileItem* item, const QPixmap& pix)
+void MonthWidget::slotGotThumbnaiL(const KFileItem* , const QPixmap& pix)
 {
-    imagePath_ = item->url();
-
-    CalSettings::instance()->setImage(month_,imagePath_);
-
+    if ( pixmap_ )
     delete pixmap_;
     QPixmap image = pix;
@@ -132,5 +161,19 @@ void MonthWidget::mouseReleaseEvent(QMou
     if (e->button() == Qt::LeftButton) {
         KURL url = KIPI::ImageDialog::getImageURL(this, interface_);
-        if (url.isValid()) {
+        if (url.isValid())
+        {
+            // check if the file is an image
+            if ( QImageIO::imageFormat( url.path() ) )
+            {
+                imagePath_ = url;
+                CalSettings::instance()->setImage(month_, imagePath_);
+
+                KIconLoader* iconLoader = KApplication::kApplication()->iconLoader();
+                QPixmap pix = iconLoader->loadIcon("image", KIcon::NoGroup, 64 );
+                if ( pixmap_ )
+                    delete pixmap_;
+                pixmap_ = new QPixmap( pix );
+                update();
+
             KURL::List urls;
             urls << url;
@@ -141,4 +184,10 @@ void MonthWidget::mouseReleaseEvent(QMou
                     SLOT(slotGotThumbnaiL(const KFileItem*, const QPixmap&)));
         }
+            else
+            {
+                kdWarning( 51001 ) << "Unknown image format for: "
+                                   << url.prettyURL() << endl;
+            }
+        }
     }
     else if (e->button() == Qt::RightButton) {


Comment 4 Renchi Raju 2004-12-28 20:42:06 UTC
The reason why your thumbnails are not showing is because your setting for the generating previews is lower than the size of the images you have. go to kcontrol->file manager->previews & meta-data-> and increase the "maximum file size" for which previews will be generated to a larger number (> than your maximum image size). there was an additional problem dependent on this which has been fixed.