Skip to content

Instantly share code, notes, and snippets.

@seven332
Created January 9, 2016 07:28
Show Gist options
  • Save seven332/206e2dd790b3f0016cd9 to your computer and use it in GitHub Desktop.
Save seven332/206e2dd790b3f0016cd9 to your computer and use it in GitHub Desktop.
# coding=utf-8
"""
Copyright © 2016 Hippo Seven
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
"""
import os
import sys
from PIL import Image
def resize_png(f):
Image.open(f).convert('RGBA').save(f)
def handle_dir(d):
for f in os.listdir(d):
path = os.path.join(d, f)
print path
if os.path.isfile(path) and path.endswith('.png'):
resize_png(path)
elif os.path.isdir(path):
handle_dir(path)
def main():
if len(sys.argv) > 1 and os.path.isdir(sys.argv[1]):
handle_dir(sys.argv[1])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment