Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
10 posts Page 1 of 1
The script that re-sizes/crops images for Couch is called TimThumb and it uses PHP's GD Library. Unfortunately, often when pictures contain rich color and/or fine detail, GD will fail to preserve these characteristics in re-sized images. An alternative to GD is the ImageMagick Engine. If we replace GD with ImageMagick, there is potential for a substantial increase in the quality of re-sized images. One obstacle to using ImageMagick however is a lack of support from hosting providers. Some hosts do not have ImageMagick installed or alternatively only have very old versions of the software available.

balloons-gd.jpg (73.53 KiB) Viewed 6342 times
balloons-im.jpg (122.62 KiB) Viewed 6342 times
Download the images and switch between them to more easily spot the differences (focus on one balloon at a time). Photograph by Nicolas Raymond.

File Size
Please be aware that with higher quality images, file size will increase as well. Sometimes the difference in file size between GD and ImageMagick re-sized images can be substantial, even when the visual improvement is negligible. It is therefore recommended that you lower the quality value for your image/thumbnail editable regions to keep this growth in check.

Your host needs to have a recent version of ImageMagick installed and allow the use of PHP's 'exec' function. Contact your host if you are uncertain you are able to meet these requirements. I can confirm that this script works fully with ImageMagick 6.4.8 and later. Version 6.2.8 does not support thumbnail crop positions. I haven't tested any versions in-between... Please be aware that there is a difference between ImageMagick and Imagick. This script does not provide support for the Imagick PHP library.

1. Extract the zip file contents. Navigate to line 35 of 'timthumb-im.php' and replace 'convert' with the location of your host's ImageMagick convert program. This could be '/usr/bin/convert', '/usr/local/bin/convert', or something else... Again, contact your host if you are not sure.

2. Navigate to 'couch/includes/timthumb.php' and rename the file to 'timthumb-gd.php'.

3. Rename 'timthumb-im.php' to 'timthumb.php' and place it in the 'couch/includes/' folder.

4. Test that the new script is not generating any errors and is correctly saving images.

Also hosted on GitHub at
(2.92 KiB) Downloaded 411 times
Let me know if you have any questions. Also, please keep your expectations realistic.

Thank you for sharing this.
There is indeed a perceptible difference in image qualities of GD and ImageMagick.
It is a shame that ImageMagick is not more widely available at web hosts as of now.
Anyways, those who have it at their disposal, I am sure will appreciate your effort.

Thanks again.
After seeing the direct comparison I installed it right away :) thank you!
i was wondering if this works with the grayscale addon (
I am not sure how I missed your post @cmdillon. There should not be a conflict with the grayscale addon.
hi cheesypoof,

i tried it with the greyscale addon, but didn't work. maybe it's not the addon but my instance of ImageMagick. really don't know.
My apologies @cmdillon; I was very mistaken. As it turns out, both the grayscale and watermark addons use the save_image function defined in timthumb.php. This function had been modified in my replacement script and thus broke those addons. In my defense though, this script did predate them...

I refactored some portions of the code and restored the original function. Please update your script to that of

Thanks for the report.
I did a website for a client that sells lamps. She started to add lamps(products) with Couch, but the generated thumbnail that is used for cart checkout table is totally different color.

Like it has been greyscaled to some extent. Anyway, of course she can't leave it like this for her customers.

Any tips? Aside from using a custom field instead of the product_thumb?
I have not seen anything like that @madebym...

Please post one of the images and its thumbnail, as well as the version of ImageMagick.

I am not sure what you are referring to in this case when you say 'custom field'. Certainly though, if this script appears to be giving you problems, revert back to the original timthumb.php script. You should be able to click the 'Recreate' button in the admin panel for the problematic thumbnails.
@cheesypoof False alarm !! The quality of thumbnail was set to default(80), once increased to 100 the images got they color back :)

But it was a visible loss of vibrancy in colors when set to default image quality. Guess the default is good for many cases, but not for ecommerce.

Imagine you buy one product and it looks quite different color wise on the cart and checkout pages :o

Anyway, all good now !
10 posts Page 1 of 1

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests