Loading...

image-sig@python.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [Image-SIG] Does PIL ImageDraw create shape objects or stain pixels? Chris.Barker Thu Nov 10 14:00:17 2011

On 10/26/11 2:49 PM, Jeff Brantley wrote:
I am working on code to draw tens or hundreds of thousands of squares
and connecting lines using the tkinter canvas, and it is incredibly slow
because, as I understand it, the canvas keeps the individual shape
objects around in memory and tests for the current visible bounding box
to touch them, and redraws them.

That may or not be why it's slow...

I am wondering whether PIL's ImageDraw module behaves in this manner, or
whether it instead just paints the shapes onto a raw pixel buffer,
effectively "staining" the pixels, rather than holding onto thousands of
identical objects.

you are right -- PIL just does the drawing, and is not any kind of object canvas.

I assume that this would be much faster if it is the
case.

perhaps, and perhaps not. Keeping the objects around per-se isn't necessarily a slow process. But certainly PIL's drawing is simpler.

I've found PIL drawing to be pretty slow, but for your use case, it may well be fine.

For higher quality, you may want to look into Agg-draw:

http://effbot.org/zone/pythondoc-aggdraw.htm

I don't know if it's been rolled into PIL or not.

Do you need a GUI of some sort? or are you just drawing an image to save to a file or something?

-Chris









Thanks for your help,
Jeff


_______________________________________________
Image-SIG maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/image-sig


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[EMAIL PROTECTED]
_______________________________________________
Image-SIG maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/image-sig