/images/sample.jpg  /images/sample.jpg  /images/sample.jpg  images/sample.jpg 

Description:

Very useful for creating multiple sizes of image urls from single images
Creates a thumbnailed image based on info passed to it via get. 
 
Images are cached on the server, so server processing overhead is only
needed for the first time the script runs on a particular image.

Usage:

<img src="thumb.php?file=FILE&size=SIZE"> - to size the thumbnail to fit a square
<img src="thumb.php?file=FILE&sizex=SIZEX&sizey=SIZEY"> - to size the thumbnail to fit a rectangle
<img src="thumb.php?file=FILE&size=SIZE&quality=QUALITY&nocache=NOCACHE"> - to set a thumbnails quality 
  
Where:

  • FILE = the file to retrieve
  • SIZE = the maximum size of the thumbnail in pixels
  • SIZEX = the maximum width of the thumbnail (height adjusted accordingly)
  • SIZEY = the maximum height of the thumbnail (width adjusted accordingly)
  • QUALITY = an integer from 0-100 specifying the resulting jpeg quality of the image
  • NOCACHE = an integer 1 or 0. If set to 1, the cached thumbnail is deleted and recreated (use if the source image changes)

Features:

  • Server caching of images
  • Creation of jpeg thumbnails inline, on the fly
  • Can be used for non-local images, if allow_fopen_url in the php configuration is set to true

Requires:

GD Library

Installation:

The script should work with GD versions 1 and 2, and Linux and Windows servers

Licensed under the GNU Lesser General Public License as published by the Free Software Foundation.
Copyright © 2005 Chris Tomlinson.

Download:

Download thumb.php v1.1

Version Changes:

Changes:
0.1 - first release
0.2 - converted cache thumbnail from png to jpeg
0.3 - fixed error where files weren't being cached properly
0.4 - allowed non local urls (if allow_url_fopen is on), quality and nocache switches
0.5 - allowed maximum x and y settings (for scaling images to fit non square sizes)
0.6 - allowed tagging of images (with the get query placing the text in the bottom left hand corner of the image)
0.7 - fixed gd_info error for php<4.3
0.8 - added gif support (for gd 2.0.28)
0.9 - now supports native outputting of png, jpg and gif formats
1.0 - doesn't fail if the cache file can't be created
1.1 - removed a few more notices

Comments

  • classifieds says:
    this script is great! I will use it on future projects THANK YOU !!!!
    12:56am 19 Aug 10

  • daniel says:
    very handy script indeed.
    2:50pm 4 Mar 10

  • Teacher says:
    Amazingly simple script. I fought with another one for hours and gave up. I got this one to work perfectly in 5 minutes. Everything should be this easy.
    3:12pm 17 Feb 10

  • dave e says:
    just what i was looking for, thanks
    9:45pm 27 Oct 09

  • fluffy says:
    perfect. exactly the script i was looking for. worked flawlessly the first time, everyone's excited to start using it.
    4:09am 29 Sep 09

  • satish says:
    nice script very helpfull. thanks a lot
    11:30am 4 Sep 09

  • Worlds Hardest Game says:
    Thank you very much, this script is very simple but effective and exactly what I have been looking for. Stam
    7:16pm 24 Aug 09

  • Shawpy says:
    How can you make this script create a thumbnail and then set the thumbnail onto a sqaure black background? (for vertical centering purposes on an image gallery) Also what is the server load creating these thumbnails on the fly each time a person visits the page? I have a lot of visitors to the site I am using it on.
    9:55pm 10 Aug 09

  • Ooh! says:
    Thank you very much for this script and it's very easy to config too.
    5:35pm 15 Apr 08

  • Ricardo Martinez says:
    Hi. Excelent script, i made some changes because the size prameter for square images didn't work, so if you want the new version let me know. Ricardo from Dominican Republic.
    8:11pm 26 Mar 08

  • Amir Aziz says:
    Fantastic script and its quality, Easy to use.
    9:45am 9 Feb 08

  • Daniel says:
    why is tif not supported?
    11:24am 14 Jan 08

  • Daniel says:
    why do you not support .tif files?
    11:23am 14 Jan 08

  • suthann says:
    Coool script..thanks alot...it helped meh alot..thanks soo much..keep up the good work..
    3:39pm 26 Dec 07

  • MRT says:
    I can Give width .. it is now working thumb.php?file=./uploads/cc_articles/59&size=200&quality=100&nocache=NOCACHE
    6:44pm 2 Dec 07

  • chris says:
    Great script! I made a small modification to send back a "304 Not Modified" header to make use of client-side caching. It definitely sped things up for me! Thanks! chris
    8:12pm 3 Sep 07

  • www.marviins.nl says:
    Many many thnx for this amazing script. Very easy to use, very good quality script
    6:30pm 29 Aug 07

  • MM says:
    Thank you very much for the script
    9:22pm 15 Feb 07

Leave a comment