19 Feb 2010 | Resizing images on the fly using PHP

Geonews: news from a location on a particular date

I'm currently working on the new Twaweza website (not online as I write this), and needed a library to resize images on the fly with PHP, without having to store the resized images.

Being a typical lazy coder, I looked around for an existing library and found a useful start in Simon Jarvis' library for resizing images on the fly. It almost served my needs, besides the ability to resize images to fit inside a user defined box.
So I added the function resizeToMax.

The updated file can be found in my dropbox. Obviously, change the extension to php to use it.

Update (March 2010): I also included a resizeToMin function which resizes an image so that it fits over the passed box size. This is the same as what Flickr uses for their square thumbnails.

Tagged with: code Flickr image PHP resizing thumbnails


  • Me

After obtaining an M. Sc in maths, Babak Fakhamzadeh started with an office job at a major blue chip company but soon realised he'd do better on his own. Babak is often on the move, with a restless desire for travel, a penchant for doing good and a love for visual and experimental art. Together with Eduardo Cachucho, he won the World Summit Award in the m-Tourism and Culture category in 2012 for Dérive app. With Ismail Farouk, he won the Highway Africa new media award in 2007 for Soweto Uprisings . com. Check out Babak's CV.

September 2015