views:

333

answers:

5

Hi,

I'm currently resizing images in PHP, and my current code takes about 2-2.2 seconds (not including upload time) to resize an image to two sizes, one thumbnail size, and one medium-sized. Can anyone recommend a framework or class that I could download that would resize the images quickly?

Thanks.

+1  A: 

Ive used this once before and it worked fine

http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php

Not sure if its quicker that what you already have though.

neilc
+6  A: 

I have used ImageMagick for a long time, and it works great.

Arkain
+1  A: 

I use this one:
http://dev.expocom.nl/functions.php?id=104

Haven't really benchmarked it but it works.. can you find out which part of your code takes the largest part of the required time?

MSpreij
+2  A: 

As someone coming from in the Ruby and native side of things, I would recommend avoiding ImageMagick based solutions since it eats large volumes of memory and happens to be slow in the first place.

I've found that a lot of scripting languages tend to wrap one of three free image libraries: ImageMagick, ImageScience and GraphicsMagick. All three of these libraries have relatively poor performance when it comes to image resizing. If you have to choose between the three, GraphicsMagick has the best performance while ImageScience consumes the least memory.

However, out of the free libraries, I'd suggest going with something based on either VIPS or NetPBM, which are a great deal faster and consume far less memory than their more popular counterparts.

If money isn't a problem, then wrapping something like Intel IPP for Linux will probably be the fastest alternative. However, IPP is about $200 USD.

David Ma
do either of the solutions you offered contain plugins/API's for PHP?
daniel
I'm not a PHP guy so I can't vouch for these, but a quick search shows:http://sourceforge.net/projects/phpnetpbm/If you just need to do image sizing, using exec() with appropriate command line will get the job done.
David Ma
A: 

I recommend this (commercial) one:

http://intermedia.pixelboxx.com/

Pros: straight-forward and consistent API, close to HTML/JavaScript terms (easy to learn), very fast, URL + JavaScript API, free demo

kos