views:

121

answers:

2

I've created a script which implements jCrop to crop an image before displaying it. In the CMS the client needs to be able to upload logos, which fit a specific size as determined by our designer.

So I think I'm looking for something which can crop, resize and save out the original, a specific sized version and potentially other thumbnail sizes.

Please can anyone suggest a good solid, and pretty bullet proof method for this? So far I am using GD and passing in jCrop coords to create an image. It's causing chaos for the client, as they are uploading huge images and small ones and obviously having all kinds of issues with the results not being correct.

I figured that a class might be an idea, and I found this, http://pear.php.net/package/Image_Transform although I haven't actually tried it out yet.

As image uploads are such a mainstream feature of sites now, what are peoples tips for handling this potential black hole of user input?

Presently I validate on upload for <100kb and bmp, gif, jpg and png

+1  A: 

There is a pretty solid image manip class at this link: http://www.codewalkers.com/c/a/GUI-Code/PHP-Image-Manipulation-Class-10/

Excerpt from the page linked above:

This PHP class can be used to perform several types of image manipulation operations.

It can:

  • Rescale images to fit in a given width or height keeping (or not) the original aspect ratio
  • Flip images horizontally or vertically
  • Rotate images by a given angle, filling the empty spaces with a given color
  • All operations preserve transparency!
  • The class does all the error checking for the source and target file so you don't need to worry about that

The class supports loading and saving images in the GIF, JPEG and PNG formats.

The code is very well documented and there is a good documentation and example to get you started

jordanstephens
Cracking, thank you! I'll give it a try :) It does look a bit old, the blog post being created in 2006
DavidYell
A: 

Managed to get a solid enough solutions using the PEAR class! :D

DavidYell