Подушка «Питон»: проблема с прозрачностью порогаPython

Программы на Python
Гость
Подушка «Питон»: проблема с прозрачностью порога

Сообщение Гость »


Я пытаюсь конвертировать to 256 8 bits indexed colors, but I can't figure out how to set a threshold to make partial transparent pixels become transparent, original and result:
Изображение
Here's my code:

Код: Выделить всё

from PIL import Image
import os

def convert_to_indexed_bmp(input_image_path, output_bmp_path):
img = Image.open(input_image_path)

indexed_background_color = (0, 255, 0)

img_with_indexed_background = Image.new("RGBA", img.size, indexed_background_color)
img_with_indexed_background.paste(img, (0, 0), img)

img_indexed = img_with_indexed_background.convert("RGB").convert("P", palette=Image.ADAPTIVE, colors=256)

img_indexed.save(output_bmp_path)

input_folder = "splash.png"
output_folder = "splash.bmp"

convert_to_indexed_bmp(input_folder, output_folder)
How to cut off this green edges?


Источник: https://stackoverflow.com/questions/781 ... ansparency

Вернуться в «Python»