JPEG quality/compression on thumbnail and resized images

jstricker

Joined: 2009-05-07
Posts: 8
Posted: Tue, 2009-05-19 17:51

I'm probably missing something obvious, but I don't see how one adjusts the amount of JPEG compression used on thumbnails and resized images. Based on the file sizes I'm seeing, I'd guess that the graphics engines are using the highest setting. Further, I'm guessing the graphics engine is choosing this option since my source JPEG files are set to the highest quality in my camera. Is there a way to force a particular value?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2009-05-20 04:06

I filed this ticket: http://apps.sourceforge.net/trac/gallery/ticket/293 and added a feature for this in r20879. You can configure it in Admin > Settings > Advanced (look for "image_quality"). Enjoy!
---
Gallery 3 problems? Check gallery3/var/logs before you post!
Gallery 3 nightlies: http://www.gallery2.hu/download/Gallery3/gallery3nightly.tar.gz
Gallery 3 subversion: http://codex.gallery2.org/Gallery:Using_Subversion#Quick_Start

 
jstricker

Joined: 2009-05-07
Posts: 8
Posted: Wed, 2009-05-27 04:33

What about making the compression step into a graphic rule? As it is now, I would think multiple JPEG compressions would have a fairly negative effect on the image quality since each iteration is lossy (I think, but I'm definitely not a JPEG expert).

/**
* Compress an image based on the image_quality setting. The options parameter is ignored.
*
* @param string $input_file
* @param string $output_file
* @param array $options
*/
static function compress($input_file, $output_file, $options) {
if (!self::$init) {
self::init_toolkit();
}

Image::factory($input_file)
->quality(module::get_var("core", "image_quality"))
->save($output_file);
}

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Fri, 2009-05-29 23:22

As I understand it, it's not going to do multiple compressions over the image, it's just setting a baseline for the quality level for the conversion. If you've got the time, it would be useful to model a few different approaches. Take a high-megapixel image and try the approach we're doing now (just trapdoor the exec() cmd to get the exact imagemagick commands we're running), then try some alternates and see if you can come up with something better.

---
Gallery 3 problems? Check gallery3/var/logs before you post!
Gallery 3 latest code: http://github.com/gallery/gallery3/zipball/master
Gallery 3 from git: http://codex.gallery2.org/Gallery:Using_Git