You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by jonathan vanasco <jv...@mastersofbranding.com> on 2005/03/06 00:02:14 UTC

[Slightly OT] Standardizing image uploads/making thumbnails

I'm trying to figure out a way to standardize image uploads and make 
thumbnails

What have people here found good to use (a2/mp2)?
As far as CPAN mods/interfaces go
	GD seems to be faster , but it looks  awful
	ImageMagick looks better, more stress on the server
	Imager looks  simple, but even more stress

Some of those have Apache mods that  are long unmaintained

The  netpbm suite looks ok, but  a potential hassle as it would require 
several pipes to do a transform



Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by jonathan vanasco <jv...@mastersofbranding.com>.
OMFG

i don't know c -- i hacked something together tonight in 4 hours (it 
would have taken 4minutes if i knew c)

average time for a resize now -- 0.017

that's roughly 1/6 the speed of PIL, and 1/12th of ImageMagick

AMAZING

On Mar 26, 2005, at 2:08 PM, D. Hageman wrote:

>
> I have one more suggestion for you to try called "epeg".  You can find 
> it here.
>
> http://www.enlightenment.org/index.php?id=27
>
> It is one of the enlightenment foundation libraries.  It is supposedly 
> really fast.  You might want to check it out as well.  I don't think a 
> perl module exists for it at this time, but Inline::C should work just 
> fine.


Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by "D. Hageman" <dh...@dracken.com>.
I have one more suggestion for you to try called "epeg".  You can find it 
here.

http://www.enlightenment.org/index.php?id=27

It is one of the enlightenment foundation libraries.  It is supposedly 
really fast.  You might want to check it out as well.  I don't think a 
perl module exists for it at this time, but Inline::C should work just 
fine.


On Sat, 26 Mar 2005, jonathan vanasco wrote:

>
> This is just a followup to an earlier question about efficiently thumbnailing 
> images.
>
> I benched everything I could find, which meant the following:
>  netpbm
>  ImageMagick
>  GD
>  Imager
>
> And did so using a 90kb jpg that is scaled to fit a 200x200 box
>
> The GD  jpgs didn't look good.  So i threw them out of the running.
>
> Using netpbm, you chain different apps from one to another.  djeg/cjpeg from 
> the underlying jpg library offer their own methods to read/write from the 
> netpbm formats.  reading is considerably faster.  writing was often faster, 
> and over several thousand benchmarks proved to be faster -- but was much 
> slower at times as well.
> 	That said, i benchmarked each section
> 	reading a jpeg file
> 		djpeg				0.029
> 		jpegtopnm			0.169
> 		writing a jpeg file
> 		djpeg				0.003
> 		jpegtopnm			0.006
> 		scaling a jpeg file 			pnmscale 
> 0.199
>
> Full benchmarks
> 	Fastest NetPBM options  	- 0.241
> 	ImageMagick 			- 0.223
> 	Imager  				- 0.402
>
> Every thread I've read has suggested that Imager and Image magick would be 
> the slowest.  ImageMagick ended up being the fastest.
>
> I couldn't help myself, and tried doing it in python as well, using the 
> Python Imaging library.
> Within the python environment, it took .07 to do the same 
> read/transform/write
> Launching a shell script that uses that library from perl (which would 
> include the time of invoking a python interpreter) :
> 	PythonImaging Library 	- 0.113
>
> Perhaps this info will help someone else in the future.
>

//========================================================\\
||  D. Hageman                    <dh...@dracken.com>  ||
\\========================================================//

Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by jonathan vanasco <jv...@mastersofbranding.com>.
This is just a followup to an earlier question about efficiently 
thumbnailing images.

I benched everything I could find, which meant the following:
   netpbm
   ImageMagick
   GD
   Imager

And did so using a 90kb jpg that is scaled to fit a 200x200 box

The GD  jpgs didn't look good.  So i threw them out of the running.

Using netpbm, you chain different apps from one to another.  djeg/cjpeg 
from the underlying jpg library offer their own methods to read/write 
from the netpbm formats.  reading is considerably faster.  writing was 
often faster, and over several thousand benchmarks proved to be faster 
-- but was much slower at times as well.
	
That said, i benchmarked each section
	reading a jpeg file
		djpeg				0.029
		jpegtopnm			0.169
	
	writing a jpeg file
		djpeg				0.003
		jpegtopnm			0.006
	
	scaling a jpeg file 	
		pnmscale 			0.199

Full benchmarks
	Fastest NetPBM options  	- 0.241
	ImageMagick 			- 0.223
	Imager  				- 0.402

Every thread I've read has suggested that Imager and Image magick would 
be the slowest.  ImageMagick ended up being the fastest.

I couldn't help myself, and tried doing it in python as well, using the 
Python Imaging library.
Within the python environment, it took .07 to do the same 
read/transform/write
Launching a shell script that uses that library from perl (which would 
include the time of invoking a python interpreter) :
	PythonImaging Library 	- 0.113

Perhaps this info will help someone else in the future.


Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by jonathan vanasco <jv...@mastersofbranding.com>.
The consensus on perlmonks seems to be  that  GD and ImageMagick can be 
a pain.

I'm gonna try netpbm and Imager.  i've used NetPBM in the past and 
found it  pretty fast and super easy to install.


On Mar 5, 2005, at 11:57 PM, Sam Tregar wrote:
> Krang (http://krang.sf.net) uses Imager to do thumbnailing, not
> because it's any better than the other two but because it's much
> easier to compile and install.  I've often had problems getting GD and
> ImageMagick installed but Imager has been very easy to support.
>
> -sam


Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by Sam Tregar <sa...@tregar.com>.
On Sat, 5 Mar 2005, jonathan vanasco wrote:

> What have people here found good to use (a2/mp2)?
> As far as CPAN mods/interfaces go
> 	GD seems to be faster , but it looks  awful
> 	ImageMagick looks better, more stress on the server
> 	Imager looks  simple, but even more stress

Krang (http://krang.sf.net) uses Imager to do thumbnailing, not
because it's any better than the other two but because it's much
easier to compile and install.  I've often had problems getting GD and
ImageMagick installed but Imager has been very easy to support.

-sam

Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by Eric Wilhelm <ew...@sbcglobal.net>.
# The following was supposedly scribed by
# jonathan vanasco
# on Saturday 05 March 2005 05:02 pm:

>I'm trying to figure out a way to standardize image uploads and make
>thumbnails
>
>What have people here found good to use (a2/mp2)?

I've been considering a rewrite of Apache::AutoIndex (if Philippe 
doesn't beat me to it), and maybe the thumbnail generation needs to be 
abstracted out into a separate module?

One thing that I had planned was to handle thumbnails according to this 
(proposed) standard:

  http://jens.triq.net/thumbnail-spec/

Which eliminates the clutter of thumbnail files (and the associated 
edge-case of "do not generate thumbnails for thumbnails") (and maybe 
also allows multiple web-based services to utilize a common thumbnail 
cache (I'll propose that ~/.thumbnails/ corresponds to 
$DOCUMENT_ROOT/.thumbnails/, but maybe there's a good argument for it 
living in $TMP (except that there the cache could get lost at reboot.))

>As far as CPAN mods/interfaces go
> GD seems to be faster , but it looks  awful

That seems to be the consensus.  However, if you aren't doing anything 
very complex (e.g. just resize/rotate) it might be worth it.  

> ImageMagick looks better, more stress on the server

ImageMagick does support more formats.

>The  netpbm suite looks ok, but  a potential hassle as it would
> require several pipes to do a transform

Maybe that would be better with IPC::Run?  (But I won't claim to know 
how the forking that it does interacts with a2/mp2 (yet.))

--Eric
-- 
"Matter will be damaged in direct proportion to its value." 
                                        -- Murphy's Constant
---------------------------------------------
    http://scratchcomputing.com
---------------------------------------------

Re: [Slightly OT] Standardizing image uploads/making thumbnails

Posted by Todd Finney <tf...@boygenius.com>.
At 06:02 PM 3/5/2005 -0500, jonathan vanasco wrote:
>What have people here found good to use (a2/mp2)?
 > ...
>         ImageMagick looks better, more stress on the server

How I've always handled server-side image manipulation is to skip doing it 
in the server process.  I take the upload and drop it somewhere on the 
filesystem, then have a cron job sweep through at a later time and process 
the image using ImageMagick.

I wrote the little script that I use a few years back.  It uses a 
configuration file in the upload directory to handle the site-specific (we 
host many sites) parameters for the image processing.   There's also a 
master configuration file that tells the script where the image upload 
directories are.

During the time between the upload and the processing, the user gets a 
generic "thumbnail not available" image, clicking upon which retrieves the 
full, unprocessed image.  No one's ever complained.

My understanding is that uploading and processing images inside mod_perl 
isn't really the best use of your clock cycles.  YMMV, of course.