New PIL user : How to merge images
Roberto Lopez-Gulliver
gulliver at atr.co.jp
Fri Apr 9 01:21:25 EDT 2004
try this,
import Image
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
# create/read your images
bg = Image.new('RGB', (800, 600), RED)
img = Image.new('RGB', (400, 400), GREEN)
## paste it
W, H = bg.size
w, h = img.size
xo, yo = (W-w)/2, (H-h)/2
bg.paste(img, (xo, yo, xo+w, yo+h))
## voila!
bg.show()
you may also consider using ImageMagick (www.imagemagick.org) for this special case.
hope this helps.
--r
More information about the Python-list
mailing list