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 4 years, 1 month ago
- Custom filename example with sorl-thumbnail by sajal 2 years, 3 months ago
- Image gradients on the fly by jensbreit 4 years, 11 months ago
- django-thumbs black&white support by rdugo 8 months ago
- Sorl thumbs for the lazy by renyi 1 year, 12 months ago
Comments
Did not work for me. jpg thumbs were bad, png thumbs did not resize.
#