PIL将像素设置为透明/空白

时间:2017-09-02 15:58:09

标签: python python-imaging-library

我有一个规则集,如果此单元格的列表中有颜色,则删除单元格

image = PILImage.open('revamp'+img_url)
img = image
random_name = random_filename(path="revamp/media/colorfest/")
img.save(random_name, "PNG")

pixels = image.load()   
for pos in area_id:
    pixel = pixels[pos[0], pos[1]]
    pixel = [pixel[0], pixel[1], pixel[2]]

    if pixel in colors:
        img.putpixel([pos[0], pos[1]], (0, 0, 0, 0))

img.save(random_name, "PNG")
response['status'] = 'ok'

这是我得到的,黑掉了细胞

enter image description here

原始图片enter image description here

0 个答案:

没有答案