Fast Imaging for Webserver

half.italian at gmail.com half.italian at gmail.com
Thu Jan 25 10:46:06 CET 2007


On Jan 24, 10:46 pm, "Prateek" <sure... at gmail.com> wrote:
> Hi. I'm creating a web-application using CherryPy 2.2.1. My application
> needs to process images (JPG/PNG files) to
>
> 1) create thumbnails (resize them)
> 2) overlay them on a custom background (a simple frame)
> 3) Overlay 'badges' (small 16x16 images) on top of the final thumbnail
>
> I am using PIL 1.1.5 which I have custom compiled on my development
> machine (MacBook Pro 2.33Ghz Core Duo)..
> I am using im.thumbnail for step 1 and im.paste for steps 2 and 3.
>
> The problem is that this thing is just way too slow.
> For ab -n 1000 -C session_id=2f55ae2dfefa896f67a80f73045aadfa4b4269f1http://localhost:8080/imaging/icon/def/128/255(where def is the name
> of the image - default in this case - 128 is the size in pixels and 255
> is the background color), I am getting:
>
> Document Path:          /imaging/icon/def/128/255
> Document Length:        14417 bytes
>
> Concurrency Level:      1
> Time taken for tests:   18.664 seconds
> Complete requests:      1000
> Failed requests:        0
> Broken pipe errors:     0
> Total transferred:      14680000 bytes
> HTML transferred:       14417000 bytes
> Requests per second:    53.58 [#/sec] (mean)
> Time per request:       18.66 [ms] (mean)
> Time per request:       18.66 [ms] (mean, across all concurrent
> requests)
> Transfer rate:          786.54 [Kbytes/sec] received
>
> FYI: This request returns a PNG image (image/png) and not html
>
> My understanding is that the problem is either with the CherryPy setup
> (which is likely because even in other cases, i don't get much more
> than 65 requests per second) or PIL itself (even though I'm caching the
> background images and source images)
>
> Does anyone have a better solution? Is there a faster replacement for
> PIL?
>
> Thanks in advance.
> Prateek

Check out the mac CoreGraphics bindings.  Not sure if it will be any
faster, but it can do what you want.

http://www.macdevcenter.com/pub/a/mac/2004/03/19/core_graphics.html

~Sean DiZazzo




More information about the Python-list mailing list