PHP provides a rich set of functions to generate and manipulate images. Most of these functions require the GD library, which is bundled with PHP since version 4.3.
The following code sample demonstrates the use of GD library to resize an image to generate its thumbnail. The script first saves the uploaded image in a specific location, it then generates a thumbnail version of the image and finally saves the generated thumbnail image in JPEG format.