1
多邊形外目前,做一個多邊形透明的我做,Python的PIL:使像素透明
img = Image.open("")
back = Image.new('RGBA', img.size)
back.paste(img)
poly = Image.new('RGBA', (512,512))
pdraw = ImageDraw.Draw(poly)
pdraw.rectangle([(10,10),(100,100)],
fill=(255,255,255,200))
back.paste(poly, (0,0), mask=poly)
back.show()
但我要的是這是我的多邊形外面,是透明的各個領域,我的多邊形內的區域是相同的。基本上,與我現在正在做的事情相反。
注意:ImageOps.invert(poly)不適用於RGB圖像。必須使用http://stackoverflow.com/questions/2498875/how-to-invert-colors-of-image-with-pil-python-imaging來解決這個問題。 – n00b