sorl.thumbnail processor: white background

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

  1. Letterbox for sorl-thumbnail by Mogga 4 years, 1 month ago
  2. Custom filename example with sorl-thumbnail by sajal 2 years, 3 months ago
  3. Image gradients on the fly by jensbreit 4 years, 11 months ago
  4. django-thumbs black&white support by rdugo 8 months ago
  5. Sorl thumbs for the lazy by renyi 1 year, 12 months ago

Comments

xhenxhe (on July 24, 2010):

Did not work for me. jpg thumbs were bad, png thumbs did not resize.

#

(Forgotten your password?)