Home/ Journal Bens Projects Binary Moon Archives About Ben Gillbanks Subscribe to Binary Moon Updates

Subscribe to Binary Moon Website Updates, it's Free and Easy to Stay in Touch

Search Binary Moon

Search Binary Moon

TimThumb Quality Settings

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.

4 Responses to “TimThumb Quality Settings” Leave a reply ›

  • I was in this little not aware group of people, so thanks for that ;) Sometimes it is realy good to write about something that most of us would seen as obvious.

    • Profile

      Glad it helped, and you're totally right. There's lots of things I take for granted that I forget others don't know that could help them. I will always try to share these things if I can (if I think of them) :)

  • Hi!

    I have a problem when resizing images that are smaller than the width/height parameters on the Timthumb request.

    The thing is I'm using images from different (*external*) sources, and usually those images are bigger than my width/height and the resizing works perfect, but sometimes they are smaller, and I don't want Timthumb to make them bigger, because then they look pixeled and awful...

    I've looked at the code and have tried to modify the MAX_WIDTH and MAX_HEIGHT constants based on new parameters (w2 and h2) but it didn't work (strange)

    $max_width = (int) abs (get_request ('w2', 0));
    $max_height = (int) abs (get_request ('h2', 0));
    if ($max_width > 0) define ('MAX_WIDTH', $max_width);
    if ($max_height > 0) define ('MAX_HEIGHT', $max_height);

    // ensure size limits can not be abused
    $new_width = min ($new_width, MAX_WIDTH);
    $new_height = min ($new_height, MAX_HEIGHT);

    Thanks for this script, I've been using phpthumb for years and was really tired of it, and today I found it had a security bug (it was ignoring the nohotlinking parameters to allow only certain external webpages and just accepting everything, so dangerous!!!) and found out about Timbthumb, much simpler and effective, great! :)

  • Errr actually, that max_width max_height thing was a bit of a nonsense try...

    What I want is the image to show at its real size, in the case when its width and/or height is smaller than the width/height parameters, to avoid pixeling at all

Leave a Reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About me

About BenMy name is Ben Gillbanks. I'm a lover of Video Games, WordPress, Web Development and everything in between.

I have been working on the internet since 1998, and working with computers even longer. I am a hardcore Nintendo fanboy and have owned most of their consoles at one stage or another.

Read more about me on my about page.


Follow Me


Random Link-outs

  • WPVote WordPress voting and article submission community website
  • Front Row Reviews News and Reviews for the latest movies
  • Totebo Flash games with monkeys
  • CodeAid Web development hints and tips
The Binary Network links to all my websites
bengillbanks.co.uk - Ben Gillbanks

Ben Gillbanks

All my websites under 1 roof, the easiest way to find out what I do

Pro Theme Design - premium WordPress themes

Pro Theme Design

Premium WordPress themes by web design pros (erm... that includes me)

Binary Joy - gaming news and reviews

Binary Joy

Gaming news and reviews

Binary Sun - play free online games

Binary Sun

Play and download free and paid games (many made by me)

Gaming Angel - download and play games online

Gaming Angel

Stacks of shareware games, free to try and cheap to buy