Get in touch:
01524 851 877
07718 896 553

Resizing An Image With PHP

Posted on Apr 08 2010

I came across this PHP class today that is great for resizing images. It is extremely easy to use and quite a small class. The class file can be downloaded here:

SimpleImage.php

A quick example usage to show how simple it is…

include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->resize(250,400);
$image->save('picture2.jpg');

The last time I had to do some image resizing with PHP was a number of years ago and I seem to remember it being a lot more complicated than this.

Thanks to White Hat Web Design for making this little class and making it available.

Resizing Images With Mogrify

Posted on Nov 23 2009

I needed to resize a few images in a directory recently and knew there would be a much more convenient method than opening gimp on each image, resizing etc etc.

A quick google search and I came across the ‘mogrify’ command. This is part of the ImageMagick suite. This is a nice simple command that allows you to resize images from the CLI.

An example usage would be :

mogrify -resize 640x480 *.jpg
This would resize every .jpg image in the current directory to 640×480. I needed to resize them all to a fixed width and the following code achieves this.

mogrify -resize 640 *.jpg

This will definitely make my life a little easier in the future…