Recently I have had a couple of emails about changing the amount of compression on TimThumb cropped images. The change itself is really easy, however I thought I would write it up as a reference for those who aren’t aware of it’s existence.
To change the level of compression all you have to do is edit the ‘q’ (which stands for quality) parameter in the query string.
If you don’t set the value then a default value of 80 will be used. This generally gives a good trade off between speed and quality, however if you are running a photo site or need to optimize your images for speed, then perhaps you will want to tweak things.
The allowed values are between 0 and 100.
- q=0 is the most compression you can have on the image
- q=100 is the least compression – totally uncompressed
Personally I would never use a quality of 100, it will increase the file size massively for little to no visible gain. If you want to increase the quality then around 95 is the highest you would need to go. The quality level there should be enough for most people.
Ben is a lifelong Nintendo fan who also likes to build websites, and develop games. He also buys way too much Lego.