List Info

Thread: how to change the default fill color




how to change the default fill color
user name
2006-08-06 01:40:28
Hi, all,

I'm a newbie to PIL, and is stumped with a issue: I use
following
statement to convert a image:

imout = im.transform((500,500),AFFIN,(1,0.5,0,0,0.5,0))

and I find out that some part of 'imout' is filled with
black color,
how to make PIL fill the area with other colors or just keep
it
transparent by default instead of just with black? I have
searched the
web and cannot get any ideas.

I'll appreciate any ideas. Thanks in advance.

Bruce
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
how to change the default fill color
user name
2006-08-15 21:49:06
Bruce Who wrote:

> I'm a newbie to PIL, and is stumped with a issue: I
use following
> statement to convert a image:
> 
> imout = im.transform((500,500),AFFIN,(1,0.5,0,0,0.5,0))
> 
> and I find out that some part of 'imout' is filled
with black color,
> how to make PIL fill the area with other colors or just
keep it
> transparent by default instead of just with black? I
have searched the
> web and cannot get any ideas.
> 
> I'll appreciate any ideas. Thanks in advance.

there's no way to do this in 1.1.5; to get the result you
want, you can 
warp a "solid" image using the same transform,
and use that as a mask. 
something like this should work:

     size = 500, 500
     data = im.transform(size, AFFINE, (1,0.5,0,0,0.5,0))
     mask = Image.new("L", im.size, 255)
     mask = mask.transform(size, AFFINE, ...)
     imout = Image.new("RGB", size,
"red")
     imout.paste(data, mask)

</F>

_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )