Skip to content

Instantly share code, notes, and snippets.

@khajer
Created February 18, 2019 04:28
Show Gist options
  • Select an option

  • Save khajer/7bcb26ef0af3372cfe1e5cd73522de14 to your computer and use it in GitHub Desktop.

Select an option

Save khajer/7bcb26ef0af3372cfe1e5cd73522de14 to your computer and use it in GitHub Desktop.
reduce alpha image
from PIL import Image
arImg = [
"android_128_px.png",
"apache_128_px.png",
"coupon_128_px.png",
"graphs_128_px.png",
"lab_128_px.png",
"rocket_128_px.png",
"twitter_128_px.png",
"video_128_px.png"
]
def recalcImage(filename):
# print filename
img = Image.open(filename)
img.putalpha(128) # Half alpha; alpha argument must be an int
destfile = filename.split(".")[0]+"_unactive.png"
print destfile
img.save(destfile, "PNG")
def main():
print 'haha'
for x in arImg:
recalcImage(x)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment