How to Resize an Image on Runtime in PHP

Resize an Image on Runtime in PHP

Now a day’s everyone wants to display resized image on website with different size ratio.PHP class have reusability function and can be used multiple times for resizing image. Display a thumbnail on website instead of without scaled image speed up the webpage loading and loads the complete website fast. Hence these days not only ecommerce site for product but new site, blog and almost every site using thumbnails for image display.

Image resize - PHPCluster
Image resize – PHPCluster
How to display resized image ? How to resize an image onime in PHP ?

There is a very useful and working PHP library file known as timthumb which is easy to download and put it in the folder where you wants and access it using directly its path in img resource (<img src=”you can give its path here directly”). Just call the image src with proper arguments whre need to display resized image.

Here the few steps which should be follow to resize an image.

  • Download the timthumb and put it in folder of project .
  • Just upload this file in root folder of your project using FTP
  • Call the timthumb using its argument for image display.
<img src="timthumb.php?src=vik.jpg&w=163&h=217" alt="Resized image as thumbnail" />

That’s all. In this way you can easily resize an image.

Here is the different parameters of image tag

  • Src= link or url of image
  • w= width in which image resize to
  • h= height in which image resize to
  • q= resized image quality can be defined between 0-100

Demo