Tomas Reimers
Tomas Reimers

Reputation: 3292

Best PHP Image Crop Class

I'm designing a website and I need to:

Essentially basic image upload

Instead of writing my own I'm trying to find a PHP class that let's me do all this, because as Jeff Atwood said, "never design what you can steal"

So far, Ive found:

Does anyone have any experience with these classes? Can you recommend an outstanding image upload class?

Upvotes: 21

Views: 29587

Answers (9)

YasirPoongadan
YasirPoongadan

Reputation: 739

I am using this Image crop, it working well

Simple PHP Image cCrop

Upvotes: 0

Marcio Mazzucato
Marcio Mazzucato

Reputation: 9305

I recommend SimpleImage, it is very simple, has only one file and is updated.

Example of use:

$img = new SimpleImage('image.jpg');

// Resize the image to 320x200
$img->resize(320, 200);

$img->save('new-image.jpg');

Upvotes: 2

Nikz
Nikz

Reputation: 1406

Check out JCROP Plugin

This will be uselful for all

JCROP Image cropping----deepliquid.com/content/Jcrop.html

enter image description here

Upvotes: 5

adam pery
adam pery

Reputation: 21

I recommend to use Smart Image Resizer http://shiftingpixel.com/2008/03/03/smart-image-resizer/

You get the best image quality after resizing

It's extremely simple to use. It uses image cache.

Upvotes: 2

Stefan Gabos
Stefan Gabos

Reputation: 1471

there's also this lightweight image manipulation library written in PHP called Zebra_Image that's very small, not bloated with zillion of functions you'll never use, highly optimized, with a great documentation and which is actively maintained.

Upvotes: 4

Andrew Moore
Andrew Moore

Reputation: 95424

My personal favorite Image Manipulation Library is WideImage. It makes is ridiculously easy to do that kind of task.

WideImage::load('pic.png')
->crop('center', 'center', 90, 50)->saveToFile('cropped/pic.jpg');

As for validating if it is actually an image or not, use finfo or PEAR::Mime_type. I personally prefer PEAR::Mime_Type. It uses finfo but it's just simpler to use.

Using finfo:

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $filename);

$isImage = (preg_match('#^image/#', $mimetype) === 1);

Using PEAR::Mime_Type:

$mimetype = MIME_Type::autoDetect($filename);

$isImage = MIME_Type::wildcardMatch('image/*', $mimetype);

Upvotes: 17

pepe
pepe

Reputation: 9919

If you're willing to migrate into an MVC PHP framework, I strongly recommend Codeigniter.

Besides several other classes and libraries that handle pagination, tables, security, forms, etc CI also has nice upload and image manipulation classes that are very handy and flexible. I believe they can do all you require (just not sure about jpg conversion).

You can check them out at:

Image manipulation class

File uploading class

Upvotes: 1

Hans Kerkhof
Hans Kerkhof

Reputation: 442

The class upload from Colin Verot http://www.verot.net/php_class_upload.htm is my favourite. I use in in all my projects. Like the way you 'talk' to the class and only use what your need, but gives plenty of configuration/methods to tweak it to your exact needs. Great class!

Upvotes: 4

benlumley
benlumley

Reputation: 11382

I tend to use a framework of one description or another, which cover's the file upload part. However, do have a recommendation for the cropping bit:

Imagine - https://github.com/avalanche123/Imagine

And if you want to make the uploader a tiny bit better than just an input type=file, try:

https://github.com/valums/file-uploader

Upvotes: 13

Related Questions