Skip to content

Complete TimThumb Parameters Guide

It was recently pointed out to me that there’s no single place to get a list of all the TimThumb parameters so I thought I would put together a page explaining them, and link to the relevant tutorials/ explanations.

TimThumb Parameters

stands for values What it does
src source url to image Tells TimThumb which image to resize › TimThumb basic properties tutorial
w width the width to resize to Remove the width to scale proportionally (will then need the height) › TimThumb width tutorial
h height the height to resize to Remove the height to scale proportionally (will then need the width) › TimThumb height tutorial
q quality 0 – 100 Compression quality. The higher the number the nicer the image will look. I wouldn’t recommend going any higher than about 95 else the image will get too large › TimThumb image quality tutorial
a alignment c, t, l, r, b, tl, tr, bl, br Crop alignment. c = center, t = top, b = bottom, r = right, l = left. The positions can be joined to create diagonal positions › TimThumb crop position tutorial
zc zoom / crop 0, 1, 2, 3 Change the cropping and scaling settings › TimThumb crop scaling tutorial
f filters too many to mention Let’s you apply image filters to change the resized picture. For instance you can change brightness/ contrast or even blur the image › TimThumb image filter tutorial
s sharpen Apply a sharpen filter to the image, makes scaled down images look a little crisper › tutorial
cc canvas colour hexadecimal colour value (#ffffff) Change background colour. Most used when changing the zoom and crop settings, which in turn can add borders to the image.
ct canvas transparency true (1) Use transparency and ignore background colour

Share

Join me, Bhima Bramantika, Onur, theMikeD. They're all chatting about "Complete TimThumb Parameters Guide" below ›

Read Comments

33 Comments »

  1. Why not in Parameters max min ?

    if jpg pixels 300x300px = timthumb = 100×200
    if jpg pixels 300x100px = timthumb = 100×100

    but make w&h paramer -> jpg pixel 300×100 = timthumb = 100×200 (zoom)

      • Any plans to allow percentages instead of Pixels?

        I’ve migrated to the LessIsMore framework which adjusts page width for the device/resolution viewed on…

        Timthumb is kinda redundant unless it can do something similar with percentages…

        Modern designers no longer design for a fixed width on screen then different pages for different media…and most webpages aren’t viewed on a screen at all nowadays…

      • Hi – using percentage widths won’t help with what you want to do. I’m a web designer – so I am well aware of responsive designs (try resizing your browser) however making TimThumb accept percentages won’t change anything. You should read up on responsive images – I would recommend the max-width css property. No images in responsive design change actual dimensions – they are scaled in the browser.

      • Hi Ben,
        Any plan for max-width and max-height parameter?
        I was thinking that it could be helpful when I load pictures using ajax request. so it will render resized image based on browser size instead of full image. Well, I can pass value as width param, but I can never sure that all images will be larger than given width.

        Thanks
        Rimon

  2. Great script! Love it!
    But could you please add a parameter to stop upscaling small images and keep the original size of an image if it’s smaller than the size given at w or h?!

  3. Is there a way to remove the black spaces on top and at the bottom of the image like youtube thumbnail for example ?
    In general, can I cut parts of the image with TimThumb ?

  4. I see that TT crops images when supplied with both a width and height. Is there a way to make it proportionally fit the image to a container?

    IOW: if I have an image 500 x 500 and I have a space 250 x 500, the image should be resized to 250 x 250. Is this possible?

  5. Does timthumb show image alt tags?

    The script is used on a number of websites I own and it does not appear to show image alts.

    • TimThumb resizes images – it has nothing to do with the html used on the website. You will need to edit your template to make the alt tags display.

  6. Hi.

    When I work with external files (in the same server, but a different URL), the load of that images go very slowly.
    How can I fix?

    Thanks

    • You should only use images on the same domain. It doesn’t matter what the server is – if the images are on a different domain then they will be copied over to the domain that hosts timthumb – and this is slow.

  7. Can you set a max height and max width so the picture will always fit between the dimensions, but will keep it’s proportions?

    Great work for the rest, I love your script!

  8. In my project your timthumb.php is working well.
    But I want to give the cache file name that is save in cache folder to my image src.
    Then is there any way to do it? Please suggest me!!!!!

  9. Hi
    Please, i have read the whole thing and comment and still ct equal to 0 or 1 or true does not work for gif images. It shows some black background where it was supposed to be transparent. Please, what to do ?

Comments are closed. Let's continue the conversation on Twitter.

Ok – so – TimThumb. I am sure many people have seen this already but some code exploits were recently discovered in TimThumb. Now that everything is under control once […]

css.php