Setting the corner color in rotated PIL images
rzed
jello at comics.com
Tue May 3 14:13:05 EDT 2005
"Anthra Norell" <anthra.norell at tiscalinet.ch> wrote in
news:mailman.91.1115117893.6583.python-list at python.org:
[in response to:
>> I'm using PIL to generate some images which may be rotated at
>> the user's option. When they are rotated, the original image is
>> cropped in the new image (which is fine), and the corners are
>> black (which is not, in this case). I can't find any documented
>> way to change the default fill color (if that's what it is) for
>> the corners, and PIL also doesn't seem to support a flood fill.
>> I have created a flood fill in Python, which works but which
>> markedly slows image generation.]
> I just had the same problem the other day. I solved it by
> starting out with an image large enough to retain enough white
> area following the rotation.
Well, that's a workaround I could try, but I'm half-hearted about
it. I don't like to think that it's *required*. Another possible
solution is to make the outer portion black, so the rotation seems
to do the right things, but in the cases I'm dealing with, that's
either out or more trouble than it's worth. I can haul the rotated
images into a paint program and manually touch up the corners, too,
but I don't like to have to do that either.
It seems strange that there wouldn't be some way to change the
black to another color, or (maybe just as good) to transparent. PIL
is so useful that it strikes me as an aberrant oversight. More
likely, there *is* a better way, but I just don't know it and can't
find it in the docs.
--
rzed
More information about the Python-list
mailing list