PIL TRANS TEST
## -*- coding: utf-8 -*-
"""
PILを使用して指定色をマスク抜きする
"""
from PIL import Image
#マスクを抜きたい色を指定
transCol = [0,255,12]
img = Image.open("E:/testPNG.png")
trans = Image.new('RGBA',img.size,(0,0,0,0))
width = img.size[0]
height = img.size[1]
for x in range(width):
for y in range(height):
pix = img.getpixel((x,y))
if pix[0] == transCol[0] and \
pix[1] == transCol[1] and \
pix[2] == transCol[2]:
continue
else:
trans.putpixel((x,y),pix)
trans.save('E:/testPNG_T.png')