Skip to content

Instantly share code, notes, and snippets.

@pchmn
Last active January 15, 2020 13:29
Show Gist options
  • Save pchmn/f108cb4341094fa8f991811913a8ea02 to your computer and use it in GitHub Desktop.
Save pchmn/f108cb4341094fa8f991811913a8ea02 to your computer and use it in GitHub Desktop.
import glob
import os
from PIL import Image
def changeColotToGrayScale():
os.makedirs('grayscale', exist_ok=True)
bmp_files = glob.glob('./*.png')
for f in bmp_files:
print(f)
img = Image.open(f).convert('L').resize((120, 120)).crop((0, 5, 120, 115)).resize((35, 32))
file_name = f.split('.png')[0] + '-232016ff23ff0001.png'
img.save('grayscale/' + file_name)
# img = Image.open('face-with-tears-of-joy_1f602.png').convert('L').resize((35, 32))
# img.save('greyscale.png')
changeColotToGrayScale()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment