Quick PIL tip

Thursday 26 January 2006

Just a quick note: let’s say you are using the Python Imaging Library to composite a number of images with borders into a larger image. The ImageDraw.rectangle method is fabulous for drawing borders. BUT: The ImageDraw.bitmap method is not what you want for putting little images onto the larger image. I don’t what it is good for, but it isn’t good for that. You want the Image.paste method. It works great.

Comments

[gravatar]
Fredrik 4:53 PM on 26 Jan 2006

fwiw, the "bitmap" method draws a bitmap (i.e. a 1-bit mask) in a given color. it's pretty much the same thing as "Image.paste(color, mask)"

[gravatar]
Ned Batchelder 5:45 PM on 26 Jan 2006

That would be a great sentence to add to the documentation, along with, "If you want to draw an image on an image, use Image.paste()".

[gravatar]
Vivian De Smedt 7:59 AM on 6 Feb 2006

And what about ImageDraw.Draw?

[gravatar]
Ned Batchelder 8:49 AM on 6 Feb 2006

ImageDraw.Draw is the constructor for draw objects, which have the bitmap() method that worked so poorly for me.

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.