TimThumb PHP Script Released

The custom image-resize script created for Mimbo Pro is now available as an open-source project! It’s already being used by a handful of other theme designers and I look forward to seeing what other folks do with it.

View Source Code | Live Demo


The script was scoped out by me and originally written by Tim McDaniels as a way to achieve the core functionality of phpthumb while using half the code. Ben Gillbanks then added PNG and GIF support, plus improved speed and caching.

Ben now handles TimThumb’s development and has written a series of great articles and additional documentation.

How do I use it?

Simply copy the source code into a new document called ‘timthumb.php’, place it in a folder on your site (ex: /scripts/) and call the image like this:

Some important things to note:

  • TimThumb requires the GD library, which is available on any host sever with PHP 4.3+ installed.
  • Once installed and in-use, TimThumb will automatically create a /cache/ subfolder with proper write-permissions. If your host server doesn’t allow this by default, be sure to manually change the /cache/ folder permissions to 777.
  • In addition, make sure the folder which contains TimThumb is set to 777.
  • As in the example, use absolute paths for your script and images

TimThumb allows the following parameters:

  • w: width
  • h: height
  • zc: zoom crop (0 or 1)
  • q: quality (default is 75 and max is 100)

Tagged as: