PHP Thumb Generator 2011

First things first, I want to try and ensure every post on this blog is something interesting or creative.

This post is about a small script I threw together to create thumbnails of images.  Although this is not necessarily new or “creative”, I feel it deserves to be posted as it’s small and condensed.  Other scripts on Google are heavily outdated and a lot do not work.  The ones that do work contain workarounds that are not needed due to CSS3, or things you would never use (because we’re all Web 2.0 and all).

The script created does the following things

  • Can create thumbnail by width or height (it finds the correct dimension), or choose a custom width and height
  • Quality (1-100)
  • Output as a different format
  • Save the file as a new file (or overwrite)

It’s pretty basic, but it is essentially all you need.  I’ve uploaded it and it can be downloaded here.  Since WordPress is against files ending with certain extensions (namely zip files), remove the .txt extension from the file and it should work properly.


I’ve updated the script thanks to user pradip pointing out a problem. The script can be viewed here and downloaded here

4 thoughts on “PHP Thumb Generator 2011

  1. Thanks it works well. One thing, when the image is transparent, the script does not support transparency. I had a transparent png file, I tested it with your script, the script output image is not transparent. Please fix that

      • Transparency is achieved with png files only. We can also have transparent GIF images. Update the script to support transparency for GIF images too. The script would be more flexible if we did not have to specify &t for transparency. In my case, i have a folder which stores the images uploaded by my user. So as a programmer i would not know whether the images are transparent. Is it possible to determine whether the image is transparent and then only generate transparent thumbnail for it? If you can do it, this would be a complete and very flexible script for resizing, small and easy to use script.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>