Create PHP Thumbnails On The Fly

3Rob Lewis20th Mar 2005WorkBench

In brief:

The web is great for displaying photos to family and friends, but producing web-friendly photos with thumbnails can be a real chore. I wanted to produce a script which would create a thumbnail image from a full size photo.

The Process:

For this to work, the GD library is needed.

PHP Code example

I make no claims as to the code above being my own work – it is a bastardisation of various snippets found around the web, particularly the official PHP site.

If you would like help in implementing this, please leave a comment below.

The Prologue:

  • Requires GD to be installed on server.
  • High load on server?

3 Comments Comments Feed

  1. Muhammad Ibrar (August 15, 2005, 11:19 am).

    I thankful to you to help me to create thumb nail on fly using php.I am actually a student and with the help of my friend NISHAT (we are PAKISTANI) we recently lanched our web site for entertainment and all php work is done by me.
    We intoduce young picture rating there, for this to show a thumbnail on our main page randomly pictures for attraction i require thumbnail problem.
    Again I thankful to you to leave this page for us.

    Also in my final project at BSCS degree,i work on TEXT-TO-SPEECH SYNTHESISER for our own language URDU. If you have any meterial about this please send me if you have some time.

  2. Jakob (May 12, 2006, 7:27 am).

    Hi.
    I think i can create the php file correct, but i don’t know how to display the image in the browser
    Can you help me?

  3. thumbnail creator (September 12, 2006, 3:06 pm).

    Your script can only create thumbnails from JPG images. I’ve found php thumbnail generator which can create thumbnails from JPG, PNG, and GIF images on the fly. It can save thumb on server or output it directly to the browser (useful if you do not have a lot of disk space). Very easy to use. Proportional thumbnail (not distorted). Maybe you’ll also find it useful. It is free.

    http://www.zubrag.com/scripts/thumbnail-generator.php

Add a Comment