1 2 3 4 5 6 7 8 | from PIL import Image, ImageColor
def white_background(im, requested_size, opts):
try:
background = Image.new('RGB', im.size, ImageColor.getcolor('white', 'RGB'))
background.paste(im, mask=im.split()[3])
return background
except:
return im
|
More like this
- Letterbox for sorl-thumbnail by Mogga 3 years, 1 month ago
- Custom filename example with sorl-thumbnail by sajal 1 year, 3 months ago
- Image gradients on the fly by jensbreit 3 years, 11 months ago
- Templatetag startswith + message tuned by io_error 3 years, 11 months ago
- Admin Image Widget by baumer1122 3 years, 9 months ago
Comments
Did not work for me. jpg thumbs were bad, png thumbs did not resize.
#