How can I make the images so that appengine doesn't transparent to black when resized?

I am on google appengine and am trying to resize images. I AM:

from google.appengine.api import images
image = images.resize(contents, w, h)

      

And for some images, I get a nice transparent size, while others get a black background.

How do I preserve transparency for all images?

+2


source to share


3 answers


An article on this issue: http://doesnotvalidate.com/2009/resizing-transparent-images-with-django-pil/ Google code patch: http://code.google.com/p/sorl-thumbnail/issues/ detail? id = 56



0


source


Is it on the app server or in production? There's a known bug in the app server that becomes transparent to black when linking, but it should work fine.



0


source


With PIL, you need to convert your image to RGBA like this:

im = im.convert("RGBA")

      

If you want a more efficient implementation, you can read the sorl-thumbnail sketch code. This makes good use of PIL.

0


source







All Articles