Result = (front * falpha + back * balpha * (1 - falpha)) / result Old_setting = np.seterr(invalid='ignore') Result = np.empty(front.shape, dtype='float') You should use alpha_composite_with color instead.Ĭolor - Tuple r, g, b (default 255, 255, 255) This is a very simple solution that might leave over some ugly edges, due """Set all fully transparent pixels of an RGBA image to the specified color. Thanks to the great answers, I’ve come up with the following function collection: import Imageĭef alpha_to_color(image, color=(255, 255, 255)): Is there a way to fix this? I’d like to have white background where the transparent background used to be. Or Image.open().convert('RGB').save('/tmp/output.png')īoth ways, the resulting image looks like this: ![]() Image.open().save('/tmp/output.jpg', 'JPEG') ![]() I’m using PIL to convert a transparent PNG image uploaded with Django to a JPG file. Question or problem about Python programming:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |