Merge pull request #184 from willkg/rgba-fix

Fix badge image conversion issues
This commit is contained in:
Will Kahn-Greene 2013-09-11 07:40:08 -07:00
Родитель b74fbc3a03 270895fa44
Коммит a387b0a01f
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -158,7 +158,10 @@ def scale_image(img_upload, img_max_size):
x_offset + int(crop_width), y_offset + int(crop_height)))
img = img.resize((dst_width, dst_height), Image.ANTIALIAS)
if img.mode != "RGB":
# If the mode isn't RGB or RGBA we convert it. If it's not one
# of those modes, then we don't know what the alpha channel should
# be so we convert it to "RGB".
if img.mode not in ("RGB", "RGBA"):
img = img.convert("RGB")
new_img = StringIO()
img.save(new_img, "PNG")