Creating square thumbnail of images with PHP

Sometimes listing more images and align them properly in your list or layout might not be so easy, because the images very often have different sizes and proportions; A good solution is to create square images with same proportions.

With this function you can create a square thumbnail of an original image by a simple code like this:


Image to square thumbnail

Optionally ...

If you just want to display the generated thumb file and not save an actual smaller file on server, then the second parameter should be "NULL" and in your html page have the image resize script as the img src, for example:

<img src="image_resize.php" />

And inside image_resize.php have the resize function and then:

Download php square thumb script.

Share with Google Plus