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 2 years, 10 months ago
  2. Custom filename example with sorl-thumbnail by sajal 11 months, 4 weeks ago
  3. Image gradients on the fly by jensbreit 3 years, 8 months ago
  4. Templatetag startswith + message tuned by io_error 3 years, 7 months ago
  5. Cookie based flash errors and notices (a la Rails) by alexk 3 years, 4 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?)