Quick PIL tip

Thursday 26 January 2006This is nearly 19 years old. Be careful.

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]
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]
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]
And what about ImageDraw.Draw?
[gravatar]
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:
Comment text is Markdown.