By havran on
Maybe good tip for someone who use GD library for image manipulation:
Open file image.inc in
[your DRUPAL install]/includes/image.inc
On the end of file find function image_gd_close() and replace line
return $close_func($res, $destination);
to
if ($extension == 'jpeg') {
return $close_func($res, $destination, 96);
} else {
return $close_func($res, $destination);
}
where is 96 acceptable image quality for resized pictures (for me :-)). 100 is best image quality (but large files) and lower numbers are poor image quality (but smaller files).
Comments
more info?
I'm about to try the image module, so I'd appreciate more information- I get the impression from a quick search of drupal.org that GD toolkit is typically used for the image module. A check with phpinfo() on my host confirms that it is enabled. If you don't add the line you sugest, do values default to something too high (i.e. 100) or too low (e.g. 10)? Could $extension be 'jpg' as well as 'jpeg'?
Thanks, Peter
---
Work: BioRAFT
GD
Default value for function imagejpeg (which create new jpegs) is around 75 (from imagejpeg PHP manual quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default is the default IJG quality value (about 75).
For $extension: it's correct because code of function image_gd_close() change jpg for jpeg (which create correct GD function imagejpeg())
--
My first drupal site - http://www.enigma.sk/kope-vas-muza/ (now developing)
--
My site - Svoji.SK
My first Drupal site - http://www.enigma.sk/
Thank you sooooo much
This info is JUST what i was looking for as i needed to reduce created image sizes on our site .. and honestly i didnt think i would find it on drupal as it is to do more with gd. BUT .. hats off to the drupal forum, and to you for going out of your way to provide this tip.
thanks!
rajesh
Another thankyou.
I was quite unhappy that drupal re-compressed user pictures, even though the were within the limits of dimensions and filesize. This little hack did work out, but shouldn't it really be an option within drupal?
Bjarne
Great quick fix. Thank you
Great quick fix. Thank you very much!!!
Thank you
Significant improvement in the quality of images CROPPED!!! with that change in the code.
Caroline
A coder's guide to file download in Drupal
Who am I | Where are we
11 heavens
Drupal 6
In Drupal 6 this code is in includes/image.gd.inc if someone need it. BTW this is what I was looking for a lng time ago! Thank you very much for this info.
Sasha
Print & Screen
unsharp mask
In most cases the default 75 would be enough in image quality if you apply even the default unsharp mask @ "Add Sharpen" - or customize the mask yourself in the settings.
Image toolkit
Site Config-> Image Toolkit will let you define the image quality for JPEG manipulations from 75% to whatever it's convenient for you.