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.
Background
The script was written by Tim McDaniels as a way to achieve the core functionality of phpthumb while using half the code. Ben then added PNG and GIF support, plus improved speed and caching.
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
- To really speed things up and make use of the advanced caching checks added to the script, copy these rules to your .htaccess file.
TimThumb allows the following parameters:
- w: width
- h: height
- zc: zoom crop (0 or 1)
- q: quality (default is 75 and max is 100)
Support
Please visit the dicussion forums»
Follow me on Twitter
12:27 pm
My code block didn’t come through…another try:
4:24 pm
We tried phpthumb and a lot other scripts like this, but all of them are to slow for high traffic. We must use external links like scr=”http://domain.com/images/image.jpg….” to store the images on a separated server.
Does anyone know a script that runs realy realy fast? We recently bougt a very simple script that uses database chaching and store de images on de DB. This is the fastest script that we found, but we want more speed. Any suggestions?
4:33 pm
@Josh: are you using character entities for the brackets when you paste the code?
@Jacobo: have you tried the latest version of the script, plus the htaccess rules? Depending on your CMS, you should also be able to apply additional caching rules.
2:41 pm
Sorry. Should it read…see below:
Unclear about how this parameter works
q: quality (default is 75 and max is 100)
Do I simply write: &q=100 for the max quality? So my string would look like this:
<img src="http://localhost.local/imageresize/scripts/timthumb.php?src=images/9780811864305_norm.jpg&h=&w=100&zc=0&q=100" alt="" />Thanks,
Josh
3:38 pm
@josh: yep, that’s right.
4:32 pm
and to follow up on the zoom parameter:
how does this work?
Unclear about how this parameter works
zc: zoom crop (0 or 1)
Thanks for the info.
Josh
10:46 pm
I believe the parameters just distinguish if the script crops from the top-left vs. crops from the middle and zooms outward.
4:41 pm
This script don’t work with an external image like:
Is there a way to make this work?
We need to run this in a separated server.
Regards,
3:03 pm
Hello, I am using your timthumb script and for some reason the images do not show in firefox, however they show in IE just fine. On other servers I have tested on they images display fine in firefox but on this other server I am using it does not display the images in Firefox but rather just shows the text of the ALT attribute. Then when i go directly to the image address (url://timthumb?src=image) it shows the image as the URL? i dont understand, any ideas?
4:22 pm
@Jacobo: The script is deliberately not supposed to allow accessing remote images to prevent bandwidth theft.
@casey: that’s strange, I haven’t heard of that. Feel free to email me a link.
4:53 pm
@Darren #1 : Yes the script was built to do that for bandwidth restrictions, however I have reprogrammed my timthumb.php to allow remote access as we are allowed to from the company where we will be grabbing the images from…
@Darren #2 : I think I know what the issue is I’m getting a PHPINFO report right now on it on that server, but I think it might be because the GD library is not installed on php. Anyways I’m not sure yet and I sent you the URLs by email if you want to check it out.
-Casey
5:00 pm
@ Darren : I was wrong, GD is enabled on both servers. I’m lost on this one.
8:04 pm
I encountered the same problem right after firefox updated to 2.0.0.12.
9:30 am
The image is not showing on?? I dunno why!!
My hosting has support on GD, PHP5
And im done changing the permission(777) on some of the required folders.
Still the image is not showing.. =(
Darren can u help me out man? I can give u access on my site if it is required
Heres my site: http://wptest.david-cook.info/
11:05 am
@thewebguy: I have found using absolute urls to be a problem and I have resorted to relative url’s. Maybe this is not ideal for you? But give it a try.
2:43 pm
@thewebguy:
in regards to timthumb.php — Ooops, I cannot find you the page you are looking for. Error 404
3:48 am
Hello.
Darren, I have the same problem as Jacobo, used two hosting for dividing the width of banda and my web traffic. In one case, the images stored there and in another files blog. Is not there a way to adapt the code and to be able to put the url of the other hosting a TimThumb? I think there must be some way and that we could help.
Thank you for everything.
5:45 am
Hello,
I have just one problem with this script. Before installing this script I was using the absolute path to the image for the custom field (http://mysite/wp-content…).
I don’t want to modify all the custom fields. What do I have to modify to make this script work?
5:40 pm
Thankss….
10:41 am
Can I change some code if i want to use external picture?
And How can I change it?
Thanks
2:22 am
Your code has a bug
If the header ( $_SERVER[ "HTTP_IF_MODIFIED_SINCE" ] ) isn’t set by the server and you have error reporting set to on, the script screws the JPEG http header and the image doesn’t render.
Need to put:
$gmdate_mod = gmdate( ‘D, d M Y H:i:s’, filemtime( $cache_file ) );
Before
if( isset( $_SERVER[ "HTTP_IF_MODIFIED_SINCE" ] ) ) {
6:17 am
@Aree
I actually had this same issue and fixed it myself.
Although on a couple different servers I tested it did work
And then on some others it didn’t.
7:55 pm
Hi,
Great script! I’ve had no problems using the script to create my thumbnails but to take my design forward I want to have the thumbnails it creates watermarked. What code will let me do this and where do I insert it because everything I try breaks the code or just shows me the cached image this script already generates. If it helps all my images are jpg.
Thanks
1:24 pm
What would be cool is if you could call up a file image resizes selection tool similar to the one on Wordpress Theme Headers.
3:47 pm
Я вам очень благодарен, мне понравилоÑÑŒ.
5:30 am
I didnt get TimThumb to work with GIF images. Don’t know why, tried a lot of adjusting but didn’t work out.
I’ve found SmartImage Reiszer (also PHP) which works just as easy as TimThumb, but only this one supports GIF images.
http://shiftingpixel.com/2008/03/03/smart-image-resizer/
If anyone knows how to get TimThumb to work with GIF images, please post it. I’ll read it and switch back to TimThumb.
4:15 pm
Bas, try changing line 170 from
imagegif( $image_resized, $cache_file_name);
to
imagegif( $image_resized, $cache_file_name, ceil( $quality / 10 ));
4:18 am
how can i adjust the output file size? i need the file size to be in the minimum.
11:09 pm
Is there a way to make the script or GDLib have less of a color shift from the original to the processed version? Compare…
Original:
http://www.darrenhoyt.com/timthumb/images/sample.jpg
Processed – Same size, High Quality
http://www.darrenhoyt.com/timthumb//scripts/timthumb.php?src=/timthumb/images/sample.jpg&h=300&w=400&q=100&zc=1
Thanks – great script.
11:20 pm
I think you’re seeing a difference in compression, not color. The compression is set by default to 75%, but you can change it – see line #13 at the top of timthumb.php.
11:44 pm
Thx for the reply Darren, however I did specify q=100 in my link,
9:27 am
Hey I have an error on both local and on my php5 webserver.
Warning: Cannot modify header information – headers already sent by (output started at /home/beextraordinary.nl/www/test/scripts/timthumb.php:2) in /home/beextraordinary.nl/www/test/scripts/timthumb.php on line 279
Also the picture is shown in bineare code not very usefull. I juse the following URL http://www.beextraordinary.nl/test/scripts/timthumb.php?src=http://www.beextraordinary.nl/test/images/test.jpg&w=150&h=200
Anyone any idea’s?
6:00 am
Круто, ÑпаÑибо! ;)
1:03 pm
Hey Darren,
First off, thanks a lot for this script, it looks amazing. However, I’m having a problem with it. Every image I send it, it says ‘file not found’. I made sure the cache folder was 0777 and checked that the image was accessible.
http://sheaallen.com/wp-content/themes/arthemia/scripts/timthumb.php?src=http://sheaallen.com/files/2008/08/143014w_sm.gif&w=300&h=275&zc=1&q=100
Am I doing something wrong? I appreciate your help, thanks so much again.
-Shea
6:10 am
Thanks a ton Darren!!! GD library was screwing me down. But you helped me fix that out and use timthumb.php Thanks a lot once again.
7:48 am
Is there any way to use mod_rewrite with timthumb to rewrite more friendly URLs? e.g. http://domain.com/scripts/timthumb/animage.jpg?
3:31 pm
unfortunately the timthump.php script doesn’t work anymore, after an update to wp 2.6.1. Does anybody have an idea why?
regards, Andy
6:52 pm
This looks like a great plugin and an alternative to phpthumb. However, some things are missing.. It seems it doesn’t enlarge images over the original size. I could be wrong though, but I can’t seem to get images to go over 150 pixels – which is the original dimensions (length & width).
8:26 pm
I came across this in use on the Arthemia theme, am going to implement it in a couple of my sites that have been causing me painful updates as they required stuffing around with custom fields for every article.
Awesome work!
12:55 pm
I was testing in Safari 3.1.2 and noticed that the thumbs were not generating. Instead the alt tag was printed with the “?” icon. When I refreshed, the images appeared. I clear the cache, link back to the page using timthumb and the same broken image occurs. I refresh, and there the images are again. Strange. It works in IE and FF.
A note: I am using the orderedlist version of jQuery FancyZoom, but I don’t think that is causing the issue, since it will zoom from the thumb with the same broken image.
Weird huh?
Rich