How to improve image quality of thumbnails
Posted: Fri Sep 12, 2008 12:12 am
I was always not very happy with the image quality of the generated thumbnails. Thats why I stepped deeper into it and found a way to fix it. I would like to share with you my thoughts about it.
First of all, it is important to get imagemagick running, because it offers much more options to enhance images than gd-lib.
After I did this, I searched and found the pice of code, which does the resizing job. It is located at /include/functions_images.inc.php at around line 663
it is possible to add several options, which are described at the official website
I wanted to push up
brightness, saturation (with -modulate 105% and 150%), sharpness (by using a -unsharp-mask. The amount of sharpness is adjusted with the third parameter +1.0, leave the other two alone for output on screens. Very noisy images could use a 4th parameter called +threshold) and wanted to reduce
thumbnail-size (by using the option -quality).
It is recommended to do the sharpening at the end of image processing and thats why I inserted the sharpening in the end of the command line.
It results in the following code
There is also the possibility to enhance -contrast and much more, just read the documentation.
So I hope it helps you. I would like to suggest to the developers to add sharpenig with a unsharp mask as standard procedure in the offical code. A other option would be, to allow useres to add some extra command line parameters in the configuration an pass them to the resize command.
Side note: A good explanation of the parameters of the option -unsharp could be find here
First of all, it is important to get imagemagick running, because it offers much more options to enhance images than gd-lib.
After I did this, I searched and found the pice of code, which does the resizing job. It is located at /include/functions_images.inc.php at around line 663
Code: Select all
$cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -resize '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);I wanted to push up
brightness, saturation (with -modulate 105% and 150%), sharpness (by using a -unsharp-mask. The amount of sharpness is adjusted with the third parameter +1.0, leave the other two alone for output on screens. Very noisy images could use a 4th parameter called +threshold) and wanted to reduce
thumbnail-size (by using the option -quality).
It is recommended to do the sharpening at the end of image processing and thats why I inserted the sharpening in the end of the command line.
It results in the following code
Code: Select all
$cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -resize '. serendipity_escapeshellarg($newSize) .' -modulate 105,140 -unsharp 0.5x0.5+1.0 -quality 75 '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);So I hope it helps you. I would like to suggest to the developers to add sharpenig with a unsharp mask as standard procedure in the offical code. A other option would be, to allow useres to add some extra command line parameters in the configuration an pass them to the resize command.
Side note: A good explanation of the parameters of the option -unsharp could be find here