List Info

Thread: image.transform() data outside image boundaries




image.transform() data outside image boundaries
country flaguser name
United States
2007-03-03 23:48:29
When using image.transform, (EXTENT mode) it is possible to
select an area 
which contains pixels outside the image:

  out = im.transform((0,100), Image.EXTENT, (-50, -50, 50,
50))

Is there a way to make these pixels transparent, or set
their color in
some way?

I'm loading from a GIF, and saving to a PNG. Either of these
can change,
if it will help.

Regards,
-- 
Christopher Schmidt
MetaCarta
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

Re: image.transform() data outside image boundaries
country flaguser name
Sweden
2007-03-06 04:55:42
Christopher Schmidt wrote:

> When using image.transform, (EXTENT mode) it is
possible to select an area
> which contains pixels outside the image:
>
>  out = im.transform((0,100), Image.EXTENT, (-50, -50,
50, 50))
>
> Is there a way to make these pixels transparent, or set
their color in
> some way?

there's no direct way to do this in the current version of
PIL, but you can get
the effect you're after by doing things in three steps:

    # transform the main image
    main = im.transform(size, mode, params)

    # create a mask
    mask = Image.new("L", im.size,
255).transform(size, mode, params)

    # paste the image onto an output image using the mask
    out = Image.new(mode, size, background)
    out.paste(main, 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 )