Created
September 19, 2016 23:11
-
-
Save YusukeIwaki/8dc8846308beefbb05553f8ef3522e1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
from PIL import Image | |
img = Image.open("/Users/yi01/Downloads/icon_終了.png") | |
img2 = Image.new("LA",img.size) | |
pix=img.load() | |
pix2=img2.load() | |
w,h=img.size | |
for y in xrange(h): | |
for x in xrange(w): | |
r,g,b,a = pix[x,y] | |
l=r*a/255 | |
pix2[x,y]=(l,l) if l>128 else (0,0) | |
img2.save("/Users/yi01/Downloads/icon_alpha.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment