[Image-SIG] rotate image with transparent background?
wrybread at gmail.com
Thu Jan 18 04:55:33 CET 2007
Hmm, still getting a black box. The code as it stands now in case
anything jumps out at you:
from PIL import Image
collage = Image.open("collage.jpg")
# open the pic and give it an alpha channel so it's transparent
im1 = Image.open("pic1.jpg")
# rotate it and expand it's canvass so the corners don't get cut off:
im2 = im1.rotate(32, expand = 1)
collage.paste(im2, (30, 30) )
On 1/17/07, Douglas Bagnall <douglas at paradise.net.nz> wrote:
> hi Alec,
> > I'm trying to rotate an image and have the expanded background be transparent.
> The image you get from opening a JPG won't have an alpha channel. You
> need to add it yourself with the .convert() method.
> This ought to work:
> im = Image.open("pic1.jpg").convert('RGBA')
> im2 = im.rotate(32, expand = 1)
> Douglas Bagnall
More information about the Image-SIG