Skip to content

Instantly share code, notes, and snippets.

@rodel77
Last active November 13, 2018 04:50
Show Gist options
  • Save rodel77/f7a36b2bef33943167f0ef1fae11f992 to your computer and use it in GitHub Desktop.
Save rodel77/f7a36b2bef33943167f0ef1fae11f992 to your computer and use it in GitHub Desktop.
Python batch resizing (Targeted to 32x32 & requires PIL)
import os
import PIL
from PIL import Image
if not os.path.exists("resized"):
os.makedirs("resized")
for (dirpath, dirnames, files) in os.walk("."):
for _file in files:
if ".png" in _file:
img = Image.open(_file)
img = img.resize((32, 32), Image.NEAREST)
img.save("resized/"+_file)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment