This script demonstrates how to use PHP and GD-library functions to generate thumbnails of uploaded images in the fly. The script first saves the uploaded image in a specific location (for backup or archival). It then generates a thumbnail version of the image and finally saves the generated thumbnail image in JPEG format. The script assures that the aspect ratio of original and thumbnail image are always maintained. The script supports GIF, JPEG and PNG file handling and resizing.