Bug 130996 - Wish: More control over jpeg options
Summary: Wish: More control over jpeg options
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-JPEG (show other bugs)
Version: 0.9.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-17 22:04 UTC by J. Westveer
Modified: 2018-09-02 15:18 UTC (History)
0 users

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 J. Westveer 2006-07-17 22:04:43 UTC
Version:           0.9.0-svn (using KDE 3.5.3, Debian Package 4:3.5.3-1 (testing/unstable))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.15-1-686-smp

More control options for jpeg creation.

Example, the 'advanced' save option for gimp 2.2 allows control for Optimize,
Smoothing, Progressive, use restart markers, force baseline jpeg, Sub sampling,
DCT method, and editable comment field.

I am really interested in having easy control over Subsampling.  This option was originally in jpeg to help further compress large files by averaging out similar colors, in able to reduce the jpeg file size.  The default value for libjpeg is
2x2, 1x1, 1,1 .  Digikam currently does not set this option, and therefore uses this default.  Breifly, this default option throws away half of the color information, perhaps great for vidio compression, but not for todays high-quality color photography.  

For those who might be impatient as I was, you can quickly add the following to graphics/digikam/libs/dimg/loaders/jpegloader.cpp around line #485, after the line:  jpeg_set_defaults(&cinfo);  to set the subsampling to not compress as much.
 cinfo.comp_info[0].h_samp_factor =  cinfo.comp_info[0].v_samp_factor = 1;

This will give much larger jpeg's as the color information is not as compressed.

references:
http://jpegclub.org/foveon/index2.html
http://www.wfu.edu/~matthews/misc/jpg_vs_gif/JpgCompTest/JpgChromaSub.html
file:///usr/share/doc/libjpeg62-dev/libjpeg.doc

thanks for considering.
Comment 1 caulier.gilles 2006-07-18 07:49:14 UTC
I'm agree with you. The image quality must be preserved when it possible.

There is already a file in B.K.O to move the IO file writting setting from setup to the saveas dialog (like Gimp and photoshop do). Look #123649.

We will add more JPEG compression options in this dialog later than 0.9.0.

But, for 0.9.0, added subsampling options in digikam jpegloader is a good idea. Can you give me a little patch against svn for that. 

Thanks in advance !

Gilles Caulier
Comment 2 caulier.gilles 2006-07-25 13:13:34 UTC
SVN commit 566091 by cgilles:

digikam from trunk : DImg:JPEGLoader : set horizontal and vertical Subsampling factor to 1 for a best quality of color picture compression. 
CCBUGS: 130996

 M  +10 -1     jpegloader.cpp  


--- trunk/extragear/graphics/digikam/libs/dimg/loaders/jpegloader.cpp #566090:566091
@@ -467,11 +467,14 @@
     uint&              h   = imageHeight();
     unsigned char*& data   = imageData();
     
+    // Size of image.
     cinfo.image_width      = w;
     cinfo.image_height     = h;
+
+    // Color components of image in RGB.
     cinfo.input_components = 3;
     cinfo.in_color_space   = JCS_RGB;    
-    
+
     QVariant qualityAttr = imageGetAttribute("quality");
     int quality = qualityAttr.isValid() ? qualityAttr.toInt() : 90;
     
@@ -481,6 +484,12 @@
         quality = 100;
     
     jpeg_set_defaults(&cinfo);
+
+    // B.K.O #130996: set horizontal and vertical Subsampling factor to 1 for a best 
+    // quality of color picture compression. 
+    cinfo.comp_info[0].h_samp_factor = 1;
+    cinfo.comp_info[0].v_samp_factor = 1; 
+
     jpeg_set_quality(&cinfo, quality, true);
     jpeg_start_compress(&cinfo, true);
 
Comment 3 caulier.gilles 2006-07-25 15:49:15 UTC
J. Westveer,

I mark this B.K.O file like dupplicate of #123649. Please post your future comments in this thread. Thanks in advance.

Gilles

*** This bug has been marked as a duplicate of 123649 ***