[Following up] > ----- Original Message ----- > From: "rzed" <[EMAIL PROTECTED]> > Newsgroups: comp.lang.python > To: <python-list@python.org> > Sent: Sunday, May 01, 2005 1:17 PM > Subject: Setting the corner color in rotated PIL images > > >> 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. >>
"Anthra Norell" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > 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. > > Frederic > I found another method that doesn't require the larger size and cropping :) but does require two copies of the original image :( (sort of). I copy the image and rotate the copy, then I create an all-white image of the same size as the original and rotate it by the same amount. Then I use ImageChops composite() to combine the rotated copy, the original copy, and the black-and-white version (parameters in that order). The black corners of the b/w version serve as a mask to paste the original corners onto the copy. It still seems like a lot of trouble to go to, but I don't think there is a ready solution otherwise. I think there's a C-code memset of all zeroes that underlies the black corners thing, and that's not likely to change. -- rzed -- http://mail.python.org/mailman/listinfo/python-list