PHP Image Resize, Crop & Thumbnail Creation
One of the most basic (and possible the most used) features we require out of this object is the ability to set a maximum width of an uploaded image. Usually we then also save this resized image as cache and serve up the cached version instead, but for this example we will leave that out.
Below, as you can see, I will create a new instance of Gravitywell_Image and then load() the image using the full path to it. I'll call the resize() function, specifying a maximum width and height. Now, because I'm not bothered about the height of this particular image, you'll notice I set the 'autofill' to false. This is because by nature the resize method will create a blank space around the resized image (white by default, but can be specified).
You also have the ability to crop a certain part of an image. This is also pretty useful when combined with the jQuery plugin, jCrop.
Another useful feature of this object is the ability to auto-generate thumbnails. It will take a target width and height and resize the image (including cropping if the image is a different aspect ratio to the target thumbnail size).
Requirements & File Formats
This object requires PHP 5+ with GD support. The file formats supported are GIF, JPEG and PNG.