Create image thumbnail using PHP

Hi,

Today I am going to write about a simple PHP script that enable your php project to resize image according to mentioned measurment. You may also create proportionate size thumbnail of any image. At the end I have added a download link of the script so that you can practice or make something more rich script. Lets see how the php script work:

 

  • Download the PHP Script to Create Image Thumb.
  • Extract the zip file & and copy the “thumb_image.php” file stored in the “lib” folder, then paste it to your project library.
  • Now its time to call the “thumbImage()” function that I have created in the “thumb_image.php”.

 

The thumbImage() function require 5 (five) parameters. These parameters are:

  • Source of Image that need to be resized. For example: $_FILES[“file_1”][“tmp_name”]
  • Numeric width for new Image
  • Numeric height for new Image
  • Destination directory location
  • and the last one is optional, do u need the image re-size proportionately.

 

In the script package I have included a practice environment. Functionality of all files and folder in the script package are as follows:

  • index.php : It contain HTML form to browse any image file and mention new image dimension, tell activity message, and execute the image resizing function from library. The HTML form will similarly to the below screen shot:

image resize form

 

  • read me.txt : Contain the installation process of the library.
  • img_folder : This folder is used to store new re sized images.
  • lib : This folder contain only the “thumb_image.php” file that You may use to re size your images.

 

Download the PHP script

 

Author Info

Shah Alom

Hi, This is Mohammad Shah Alom, My passion is Programming & Web Development. I am Founder of Micro Solutions Bangladesh. My Facebook profile shahalom1983 & Twitter Profile shahalom_83