Bug 123649

Summary: JPEG/PNG quality settings at the "save" dialog
Product: [Applications] digikam Reporter: Torsten Dörschel <theta-delta>
Component: Plugin-DImg-JPEGAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: jwest
Priority: NOR    
Version: 0.8.1   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In: 0.9.1
Sentry Crash Report:

Description Torsten Dörschel 2006-03-15 09:59:53 UTC
Version:           0.8.1 (using KDE KDE 3.5.1)
Installed from:    Debian testing/unstable Packages

Hi there!

Often I need to save edited images in various compression levels (e.g. for web, printing etc.) and it is very circuitous to go to the "options" menu first.

That's why I wish to have a button or so at the "Save" dialog where I can quickly check and change the compression level.
Most other programs have this feature, maybe something like in xnview would be great.

Thanks for the work done till now :-)

Torsten.
Comment 1 Marcel Wiesweg 2006-03-15 23:24:03 UTC
We could add the quality sliders like in the settings dialog as extra widgets to the bottom of the save dialog.
I think of an "Advanced" button or something, which then shows the quality sliders. Do we want that, any suggestions?
Comment 2 caulier.gilles 2006-03-16 06:01:51 UTC
Yes Marcel, we need to export all Save Image settings in saveAs dialog (TIFF, PNG, JPEG)...
But it's can be a long task, because we need to break setup implementation witch is stabilized for 0.9.0, and we need to add more advanced settings.

I recommend to delay this job later than 0.9.0 release. We need to finalize the current implementation.

Gilles
Comment 3 caulier.gilles 2006-07-25 15:49:19 UTC
*** Bug 130996 has been marked as a duplicate of this bug. ***
Comment 4 J. Westveer 2006-08-25 04:09:25 UTC
seconded,  I would like to se greater control over the options in jpeg creation.
I have tried setting the default behavior of sampling-factor from 2x1 to 1x1, and although it is good for some images, it is not good for all.  In #130996 I made a
case for making the default sampling-factor 1x1,  although I still feel that it
is a good idea, it would be a better idea under user control (I hate to admit I might have been mistaken).  Perhaps this should wait for the save dialog update.

tnx,

J. Westveer
Comment 5 caulier.gilles 2007-02-08 15:38:10 UTC
SVN commit 631592 by cgilles:

digikam from trunk : JPEG, PNG, TIFF, and JPEG2000 file save settings are now available on File Save Dialog (on the bottom). 
These settings have the save controls than the File Save setup dialog page.

Note to developpers : the settings widgets are stored in digikam/libs/dimg/loaders. All future Digikam::DImg image loaders from digikam core need to have a settings widget at this place, if settings are necessary of course. For example i would to have a native PSD IO file loader in the future. The Photoshop file format support EXIF/IPTC/XMP metadata and the 16 bits color depth (it's a TIFF like format in fact)

BUG: 123649

 M  +2 -1      libs/dimg/loaders/Makefile.am  
 AM            libs/dimg/loaders/jp2ksettings.cpp   [License: GPL]
 AM            libs/dimg/loaders/jp2ksettings.h   [License: GPL]
 AM            libs/dimg/loaders/jpegsettings.cpp   [License: GPL]
 AM            libs/dimg/loaders/jpegsettings.h   [License: GPL]
 AM            libs/dimg/loaders/pngsettings.cpp   [License: GPL]
 AM            libs/dimg/loaders/pngsettings.h   [License: GPL]
 AM            libs/dimg/loaders/tiffsettings.cpp   [License: GPL]
 AM            libs/dimg/loaders/tiffsettings.h   [License: GPL]
 M  +3 -2      libs/widgets/common/Makefile.am  
 M  +0 -1      showfoto/Makefile.am  
 M  +2 -1      utilities/imageeditor/editor/Makefile.am  
 M  +6 -2      utilities/imageeditor/editor/editorwindow.cpp  
 M  +1 -0      utilities/setup/Makefile.am  
 M  +36 -120   utilities/setup/setupiofiles.cpp  
 M  +0 -4      utilities/setup/setupiofiles.h  


--- trunk/extragear/graphics/digikam/libs/dimg/loaders/Makefile.am #631591:631592
@@ -5,7 +5,8 @@
 
 libdimgloaders_la_SOURCES = dimgloader.cpp pngloader.cpp jpegloader.cpp tiffloader.cpp \
 	                    rawloader.cpp ppmloader.cpp qimageloader.cpp iccjpeg.c \
-	                    jp2kloader.cpp
+	                    jp2kloader.cpp jpegsettings.cpp pngsettings.cpp \
+	                    tiffsettings.cpp jp2ksettings.cpp 
 
 libdimgloaders_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) \
 	                    $(LIBJPEG) $(LIB_TIFF) $(LIB_PNG) $(LIB_JASPER)
** trunk/extragear/graphics/digikam/libs/dimg/loaders/jp2ksettings.cpp #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/jp2ksettings.h #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/jpegsettings.cpp #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/jpegsettings.h #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/pngsettings.cpp #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/pngsettings.h #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/tiffsettings.cpp #property svn:eol-style
   + native
** trunk/extragear/graphics/digikam/libs/dimg/loaders/tiffsettings.h #property svn:eol-style
   + native
--- trunk/extragear/graphics/digikam/libs/widgets/common/Makefile.am #631591:631592
@@ -3,14 +3,15 @@
 noinst_LTLIBRARIES = libcommonwidgets.la
 
 libcommonwidgets_la_SOURCES = histogramwidget.cpp colorgradientwidget.cpp curveswidget.cpp \
-                              sidebar.cpp squeezedcombobox.cpp dpopupmenu.cpp \
-                              statusnavigatebar.cpp statusprogressbar.cpp 
+                              sidebar.cpp squeezedcombobox.cpp filesaveoptionsbox.cpp \
+                              dpopupmenu.cpp statusnavigatebar.cpp statusprogressbar.cpp 
 
 libcommonwidgets_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
 
 INCLUDES = -I$(top_srcdir)/digikam/libs/histogram \
 	       -I$(top_srcdir)/digikam/libs/curves \
 	       -I$(top_srcdir)/digikam/libs/dimg \
+	       -I$(top_srcdir)/digikam/libs/dimg/loaders \
 	       -I$(top_srcdir)/digikam/digikam \
 	       $(all_includes)
 
--- trunk/extragear/graphics/digikam/showfoto/Makefile.am #631591:631592
@@ -23,7 +23,6 @@
 showfoto_SOURCES = main.cpp showfoto.cpp 
 
 showfoto_LDADD   = $(top_builddir)/digikam/showfoto/setup/libsetup.la \
-	           $(top_builddir)/digikam/libs/widgets/libwidgets.la \
 	           $(top_builddir)/digikam/libs/dialogs/libdialogshowfoto.la \
 	           $(top_builddir)/digikam/libs/imageproperties/libimagepropertiesshowfoto.la \
 	           $(top_builddir)/digikam/libs/thumbbar/libthumbbar.la \
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/Makefile.am #631591:631592
@@ -12,7 +12,8 @@
 
 libshowfoto_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_KDEPRINT) 
 
-libshowfoto_la_LIBADD = $(top_builddir)/digikam/utilities/imageeditor/tools/libdimgeditortools.la 
+libshowfoto_la_LIBADD = $(top_builddir)/digikam/utilities/imageeditor/tools/libdimgeditortools.la \
+	                $(top_builddir)/digikam/libs/widgets/libwidgets.la
 
 INCLUDES = -I$(top_srcdir)/digikam/digikam \
 	       -I$(top_srcdir)/digikam/libs/widgets/common \
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/editorwindow.cpp #631591:631592
@@ -1400,12 +1400,16 @@
     connect(&imageFileSaveDialog, SIGNAL(fileSelected(const QString &)),
             options, SLOT(slotImageFileSelected(const QString &)));
 
-    options->slotImageFileSelected(m_savingContext->srcURL.fileName());
+    options->slotImageFileSelected(m_savingContext->srcURL.path());
 
-    // Check for cancel.
+    // Start dialog and check if canceled.
     if ( imageFileSaveDialog.exec() != KFileDialog::Accepted )
        return false;
 
+    // Update file save settings in editor instance.
+    options->applySettings();
+    applyStandardSettings();
+
     KURL newURL = imageFileSaveDialog.selectedURL();
 
     // Check if target image format have been selected from Combo List of SaveAs dialog.
--- trunk/extragear/graphics/digikam/utilities/setup/Makefile.am #631591:631592
@@ -4,6 +4,7 @@
 	   -I$(top_srcdir)/digikam/utilities/batch \
 	   -I$(top_srcdir)/digikam/libs/dialogs \
 	   -I$(top_srcdir)/digikam/libs/dimg \
+	   -I$(top_srcdir)/digikam/libs/dimg/loaders \
 	   -I$(top_srcdir)/digikam/libs/dcraw \
 	   -I$(top_srcdir)/digikam/libs/widgets/common \
 	   $(GPHOTO_CFLAGS) $(LIBKIPI_CFLAGS) $(all_includes)
--- trunk/extragear/graphics/digikam/utilities/setup/setupiofiles.cpp #631591:631592
@@ -21,26 +21,21 @@
 // QT includes.
 
 #include <qlayout.h>
-#include <qlabel.h>
-#include <qcolor.h>
-#include <qhbox.h>
-#include <qvgroupbox.h>
-#include <qlabel.h>
-#include <qwhatsthis.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
 
 // KDE includes.
 
 #include <klocale.h>
 #include <kdialog.h>
-#include <knuminput.h>
 #include <kconfig.h>
 #include <kapplication.h>
 #include <kseparator.h>
 
 // Local includes.
 
+#include "jpegsettings.h"
+#include "pngsettings.h"
+#include "tiffsettings.h"
+#include "jp2ksettings.h"
 #include "setupiofiles.h"
 #include "setupiofiles.moc"
 
@@ -54,29 +49,19 @@
 
     SetupIOFilesPriv()
     {
-        labelJPEGcompression     = 0;
-        JPEGcompression          = 0;
-
-        labelPNGcompression      = 0;
-        PNGcompression           = 0;
-
-        TIFFcompression          = 0;
-
-        labelJPEG2000compression = 0;
-        JPEG2000compression      = 0;
-        JPEG2000LossLess         = 0;
+        JPEGOptions     = 0;
+        PNGOptions      = 0;
+        TIFFOptions     = 0;
+        JPEG2000Options = 0;
     }
 
-    QLabel       *labelPNGcompression;
-    QLabel       *labelJPEGcompression;
-    QLabel       *labelJPEG2000compression;
+    JPEGSettings *JPEGOptions;
 
-    QCheckBox    *JPEG2000LossLess;
-    QCheckBox    *TIFFcompression;
+    PNGSettings  *PNGOptions;
 
-    KIntNumInput *PNGcompression;
-    KIntNumInput *JPEGcompression;
-    KIntNumInput *JPEG2000compression;
+    TIFFSettings *TIFFOptions;
+
+    JP2KSettings *JPEG2000Options;
 };
 
 SetupIOFiles::SetupIOFiles(QWidget* parent )
@@ -84,97 +69,35 @@
 {
     d = new SetupIOFilesPriv;
 
-    QGridLayout* grid = new QGridLayout(parent, 8, 1, KDialog::spacingHint());
+    QVBoxLayout* vbox = new QVBoxLayout(parent, KDialog::marginHint(), KDialog::spacingHint());
 
     //-- JPEG Settings ------------------------------------------------------
 
-    d->JPEGcompression = new KIntNumInput(75, parent);
-    d->JPEGcompression->setRange(1, 100, 1, true );
-    d->labelJPEGcompression = new QLabel(i18n("JPEG quality:"), parent);
-
-    QWhatsThis::add( d->JPEGcompression, i18n("<p>The quality value for JPEG images:<p>"
-                                                "<b>1</b>: low quality (high compression and small "
-                                                "file size)<p>"
-                                                "<b>50</b>: medium quality<p>"
-                                                "<b>75</b>: good quality (default)<p>"
-                                                "<b>100</b>: high quality (no compression and "
-                                                "large file size)<p>"
-                                                "<b>Note: JPEG is not a lossless image "
-                                                "compression format.</b>"));
-    grid->addMultiCellWidget(d->labelJPEGcompression, 0, 0, 0, 0);
-    grid->addMultiCellWidget(d->JPEGcompression, 0, 0, 1, 1);
-
+    d->JPEGOptions    = new JPEGSettings(parent);
     KSeparator *line1 = new KSeparator(Horizontal, parent);
-    grid->addMultiCellWidget(line1, 1, 1, 0, 1);
+    vbox->addWidget(d->JPEGOptions);
+    vbox->addWidget(line1);
 
     //-- PNG Settings -------------------------------------------------------
 
-    d->PNGcompression = new KIntNumInput(1, parent);
-    d->PNGcompression->setRange(1, 9, 1, true );
-    d->labelPNGcompression = new QLabel(i18n("PNG compression:"), parent);
-
-    QWhatsThis::add( d->PNGcompression, i18n("<p>The compression value for PNG images:<p>"
-                                             "<b>1</b>: low compression (large file size but "
-                                             "short compression duration - default)<p>"
-                                             "<b>5</b>: medium compression<p>"
-                                             "<b>9</b>: high compression (small file size but "
-                                             "long compression duration)<p>"
-                                             "<b>Note: PNG is always a lossless image "
-                                             "compression format.</b>"));
-    grid->addMultiCellWidget(d->labelPNGcompression, 2, 2, 0, 0);
-    grid->addMultiCellWidget(d->PNGcompression, 2, 2, 1, 1);
-
+    d->PNGOptions     = new PNGSettings(parent);
     KSeparator *line2 = new KSeparator(Horizontal, parent);
-    grid->addMultiCellWidget(line2, 3, 3, 0, 1);
+    vbox->addWidget(d->PNGOptions);
+    vbox->addWidget(line2);
 
     //-- TIFF Settings ------------------------------------------------------
 
-    d->TIFFcompression = new QCheckBox(i18n("Compress TIFF files"), parent);
-
-    QWhatsThis::add( d->TIFFcompression, i18n("<p>Toggle compression for TIFF images.<p>"
-                                              "If you enable this option, you can reduce "
-                                              "the final file size of the TIFF image.</p>"
-                                              "<p>A lossless compression format (Deflate) "
-                                              "is used to save the file.<p>"));
-    grid->addMultiCellWidget(d->TIFFcompression, 4, 4, 0, 1);
-
+    d->TIFFOptions    = new TIFFSettings(parent);
     KSeparator *line3 = new KSeparator(Horizontal, parent);
-    grid->addMultiCellWidget(line3, 5, 5, 0, 1);
+    vbox->addWidget(d->TIFFOptions);
+    vbox->addWidget(line3);
 
     //-- JPEG 2000 Settings -------------------------------------------------
 
-    d->JPEG2000LossLess = new QCheckBox(i18n("LossLess JPEG 2000 files"), parent);
+    d->JPEG2000Options = new JP2KSettings(parent);
+    vbox->addWidget(d->JPEG2000Options);
 
-    QWhatsThis::add( d->JPEG2000LossLess, i18n("<p>Toggle lossless compression for JPEG 2000 images.<p>"
-                                               "If you enable this option, you will use a lossless method "
-                                               "to compress JPEG 2000 pictures.<p>"));
-    grid->addMultiCellWidget(d->JPEG2000LossLess, 6, 6, 0, 1);
-
-    d->JPEG2000compression = new KIntNumInput(75, parent);
-    d->JPEG2000compression->setRange(1, 100, 1, true );
-    d->labelJPEG2000compression = new QLabel(i18n("JPEG 2000 quality:"), parent);
-
-    QWhatsThis::add( d->JPEGcompression, i18n("<p>The quality value for JPEG 2000 images:<p>"
-                                              "<b>1</b>: low quality (high compression and small "
-                                              "file size)<p>"
-                                              "<b>50</b>: medium quality<p>"
-                                              "<b>75</b>: good quality (default)<p>"
-                                              "<b>100</b>: high quality (no compression and "
-                                              "large file size)<p>"
-                                              "<b>Note: JPEG 2000 is not a lossless image "
-                                              "compression format when you use this setting.</b>"));
-    grid->addMultiCellWidget(d->labelJPEG2000compression, 7, 7, 0, 0);
-    grid->addMultiCellWidget(d->JPEG2000compression, 7, 7, 1, 1);
-
-    grid->setColStretch(1, 10);
-    grid->setRowStretch(8, 10);
-
-    connect(d->JPEG2000LossLess, SIGNAL(toggled(bool)),
-            this, SLOT(slotToggleJPEG2000LossLess(bool)));
-
-    connect(d->JPEG2000LossLess, SIGNAL(toggled(bool)),
-            this, SLOT(slotToggleJPEG2000LossLess(bool)));
-
+    vbox->addStretch(10);
     readSettings();
 }
 
@@ -187,11 +110,11 @@
 {
     KConfig* config = kapp->config();
     config->setGroup("ImageViewer Settings");
-    config->writeEntry("JPEGCompression", d->JPEGcompression->value());
-    config->writeEntry("PNGCompression", d->PNGcompression->value());
-    config->writeEntry("TIFFCompression", d->TIFFcompression->isChecked());
-    config->writeEntry("JPEG2000Compression", d->JPEG2000compression->value());
-    config->writeEntry("JPEG2000LossLess", d->JPEG2000LossLess->isChecked());
+    config->writeEntry("JPEGCompression", d->JPEGOptions->getCompressionValue());
+    config->writeEntry("PNGCompression", d->PNGOptions->getCompressionValue());
+    config->writeEntry("TIFFCompression", d->TIFFOptions->getCompression());
+    config->writeEntry("JPEG2000Compression", d->JPEG2000Options->getCompressionValue());
+    config->writeEntry("JPEG2000LossLess", d->JPEG2000Options->getLossLessCompression());
     config->sync();
 }
 
@@ -199,18 +122,11 @@
 {
     KConfig* config = kapp->config();
     config->setGroup("ImageViewer Settings");
-    d->JPEGcompression->setValue( config->readNumEntry("JPEGCompression", 75) );
-    d->PNGcompression->setValue( config->readNumEntry("PNGCompression", 9) );
-    d->TIFFcompression->setChecked(config->readBoolEntry("TIFFCompression", false));
-    d->JPEG2000compression->setValue( config->readNumEntry("JPEG2000Compression", 75) );
-    d->JPEG2000LossLess->setChecked( config->readBoolEntry("JPEG2000LossLess", true) );
-    slotToggleJPEG2000LossLess(d->JPEG2000LossLess->isChecked());
+    d->JPEGOptions->setCompressionValue(config->readNumEntry("JPEGCompression", 75) );
+    d->PNGOptions->setCompressionValue(config->readNumEntry("PNGCompression", 9) );
+    d->TIFFOptions->setCompression(config->readBoolEntry("TIFFCompression", false));
+    d->JPEG2000Options->setCompressionValue( config->readNumEntry("JPEG2000Compression", 75) );
+    d->JPEG2000Options->setLossLessCompression( config->readBoolEntry("JPEG2000LossLess", true) );
 }
 
-void SetupIOFiles::slotToggleJPEG2000LossLess(bool b)
-{
-    d->JPEG2000compression->setEnabled(!b);
-    d->labelJPEG2000compression->setEnabled(!b);
-}
-
 }  // namespace Digikam
--- trunk/extragear/graphics/digikam/utilities/setup/setupiofiles.h #631591:631592
@@ -45,10 +45,6 @@
 
     void readSettings();
 
-private slots:
-
-    void slotToggleJPEG2000LossLess(bool);
-
 private:
 
     SetupIOFilesPriv* d;