Home > Uncategorized > Image resize using PHP -TimThumb Script

Image resize using PHP -TimThumb Script

  

TimThumb is an image resize script that can be using to resize an image and can also crop an image. The croping is an awesome feature which saves the output file from streching up when both width and height are given.

Download TimThumb

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.

Usage

Simply upload the file to your root and use the code given below to use it

<img src="timthumb.php?src=/images/filename.jpg&h=150&w=150&zc=1" alt="some text" />

Please 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

TimThumb allows the following parameters:

  • w: width
  • h: height
  • zc: zoom crop (0 or 1)
  • q: quality (default is 75 and max is 100)
Categories: Uncategorized Tags:
  1. July 6th, 2010 at 15:46 | #1

    Already know about it. Thanks for the download link.

    For new programmers, you can also do a post about how to install gd library as that is must for image resize.

    Ron

  2. Rajeev
    February 19th, 2011 at 11:35 | #2

    My gifs are resized by timthumb, but gifs stop animating when resized..
    Is there any workarround for this in timthumb..?

  3. Amjath
    February 20th, 2011 at 22:09 | #3

    @Rajeev
    timthumb creates a thumb of the orginal image and stores in the cache folder. So the animation effect of the gif file will be lost.

  1. No trackbacks yet.