40 thoughts on “TimThumb Proportional Scaling Leave a comment

  1. Is there a parameter to control the color of the borders? even better could they be set to transparent?

    1. There’s nothing like this currently, but I have considered it and will likely add the colour setting. Not sure about the transparency option. That might get confusing when resizing jpgs (that aren’t transparent).

      1. are you working on this? a parameter for a color would be great. thanks for the plugin!

      2. I am not actively working on it, but it’s on my todo list and will be released in the future.

  2. Hi,
    This is a great plugin, I’m using that, and helped me a lot.
    Is there any parameter to delete the file, after create the thumbnail to save disk space?

    Thank you.

    1. Hi – there is nothing for deleting the cache file. The cache file directory is emptied over time by TimThumb (to save disk space) and so the original files are needed to recreate the thumbnails when the cache directory is emptied.

  3. Pingback: thumbs up | Gingerlime
  4. I must notice that a “crop only” cropping mode is missing. We have 3 resizing modes (0, 2, 3) and only one that crops with resizing (1). It is impossible, however, to zoom without resizing…

    1. Solved this myself, below…

      // Get original width and height
      $width = imagesx ($image);
      $height = imagesy ($image);
      $origin_x = 0;
      $origin_y = 0;

      // generate new w/h if not provided
      if ($new_width && !$new_height) {
      $new_height = floor ($height * ($new_width / $width));
      } else if ($new_height && !$new_width) {
      $new_width = floor ($width * ($new_height / $height));

      … I added …

      // prevent scale up
      if ( $width < $new_width && $height < $new_height ) {
      $new_width = $width;
      $new_height = $height;

      1. I decided not to implement this in TimThumb itself because TimThumb is meant to make the images the size you specify regardless of how the images are scaled, and this would not do that – however your fix looks like it would work in the same way my own one would.

      2. upscaled images might get prety ugly. I would love a feature like this adding borders when ever the image is too small.

        or a max-zoom so a image is not scalled up 300%.

      3. I’d vote for an additional parameter (something like up=true|false) to specify whether scaling up should be allowed.

        I think that leaves the integrity of the purpose of timthumb intact while allowing for maximum usability.

  5. On your demo timthumb has white borders, when I have come to use this on my site the “borders” appear black? Is there any way round this or am I missing something obvious?
    Really need a solution as I was planning on using timthumb for this.

    many thanks

    1. the cc parameter accepts a hexadecimal colour code to use as the crop colour when resizing. The reason my images are a different colour is that my demo code is a little out of date.

  6. Pingback: Wordpress Featured Images in Xanadu Theme | The B.O.B.
  7. Hi there, thanks for the completely brilliant timthumb. It is quite simply awesome.

    You may already know this, but I discovered today that images with a + in the filename will cause timthumb to break. Not a real problem for me, I am simply working around it by telling the client to not use + signs in filenames, but I thought you’d like to know.

    1. thanks for the tip – I need to do some testing with this to see if there’s a better way to handle these special characters. Glad you’re enjoying the script 🙂

      1. I made a ugly hack to line 210 to fix this for + characters.

        $this->src = str_replace(” “, “+”, $this->param(‘src’));

  8. Hi Ben,

    I have a problem with timthum script (so it seems) and the new version of wordpress (3.3.1) Before the wp upgrade images on my website were displaying normally but now the thumbs are streched. I have tried everything possible (file/folder permisions, cache/temp folders, reinstaling theme, tried on a fresh wp install) but no solution. I am using awake 2.5 theme by http://www.mysitemyway.com (they cant solve it either) and like said wp 3.3.1.

    Uncle google did not give any solution even after long hours of searching…

    Here is an example of distorted thumbs: blog

    Will really appreciate help!

  9. Hi Ben,

    Thank you for a great plugin! It’s been very helpful in theme customization and design.

    However, one recent aspect could be addressed: hi-res screens (such as the Retina on iPad).

    is there a clever way of making timthumb calculate the required destination size > re-size and cut the image to double the destination size (provided the image is large enough — ei 300px = 600px ) > then reduce to fit the image to destination size while keeping it’s dimensions?

    An example in use would be: an image cropped to fit a 300x200px container, but clicking to view the cropped image shows it’s actually 600x400px in zise.

    I think this would be vital to current development and demand in website design. Everyone wants to adapt to hires screens!


  10. I’m using the bold news theme from Woo Themes and it uses TT. I can’t figure out how to keep all my images from having a white border of +-2-3 pixels.

    I don’t want a border around all my images. How do I change it to give me no border? I don’t see a timthumb_config.php file in my theme directories.


    1. TimThumb doesn’t add a border to your images so the problem is likely because of the css used in the theme. Anything ese will have to go through Woo as I don’t know what they have done.

  11. I’m not the greatest developer, but I try.

    My site http://www.comicbookbabylon.com is giving me issues. I have set the sizes of the images with wordpress to be 200 wide x 300 h. But they keep showing up all messed up. And try as I might, I can’t seem to get things right. I’ve looked to my theme support for help but get nothing. Anyhelp would be great!

  12. Hi Ben,

    I was having some problems to set the canvas color while scaling the image.
    I want the canvas to be black but it always shows up in white.
    Finaly I found out what I was doing wrong.

    According to the online manual you need to add zc=2&cc=(#000000)
    But this isn’t working.
    After some try and error got it to work using zc=2&cc=000000


    Maybe a tip to adjust the online manual ?

    Kind regards,

  13. Hi Ben,

    Some of the images on my page are distorted. They weren’t always that way. When I inquired with the Woothemes team, they told me it was a timthumb scripting issue. I have activated and deactivated the script, but can’t figure out what’s going on. Please advise as to how I can fix this. My images are horribly skewed. You can take a look at http://www.lylproject.com. I”m using the Canvas 4 Woo theme.

    Your help is greatly appreciated.

    Warmest regards,

    1. The theme you are using currently doesn’t seem to be using TimThumb. The images that are stretched are the wrong size and so being squashed to fit the size. It’s not a TimThumb problem I’m afraid.

  14. Pingback: Complete TimThumb Parameters Guide
  15. Hi,

    I upload a lot of images to my WP site. WP makes the Thumbnail size, Medium size and Large size. This works fine. But the original file is also still in my image folder with the original size. I’m looking for a solution when I upload an image it will resize to a maximum width, so my orignal image is much smaller and I don’t have to manually resize every image before uploading.

    So for example. I upload an image with size 1900 x 1400. This will be stored by WP as original (which is way to big). Now I have to change this every time manually before upload the image to 1000 x 600 (for example) to make it smaller. This is a lot of work. Is this reziser script the solution for this problem?

    Kind regards,


      1. Willem did you figure out a solution? I am having trouble with this exact problem. Email me if you figured out how to get your image resized: jillian.m.hare@live.ca.

        Ben, think you need to allow timthumb to resize larger photos.

  16. When timthumb resizes an image, it puts a nice, neat, 3-5 pixel border around the image. I don’t want that border at all –I’m resizing to inside a slider, and the extra border is not only messing up the resizing, causing the bottom right corner to be cropped out, it also messes up the way the image looks. Even if I precrop the image to the exact size needed, when timthumb processes it, the image reappears with a white border.

    Is there any way to turn this border off? I don’t want it to be transparent, because that would still leave the image in the wrong place on the screen.



    1. Hi Russ – I’ve never seen or heard of anything like this. TimThumb doesn’t add any borders to the resized images so something else must be going on here.

  17. I have tried added ct=0 and the border was shown. But anyway, I would like to display the picture with color frame such like picture pasted on the color square. Is it possible to do this?

  18. I managed to fix the crop image prob on my reviews pages.
    But I cannot figure out how to fix it on my blog posts on the homepage.
    I’ve reconfigured file cache permissions from 755 to 775, and
    timthumb.php to zc=0 but if you go to my homepage,
    the 2 pics are still reading zc=1.


    Is there something else I should do?

Leave a Reply

Your email address will not be published. Required fields are marked *