Created
January 24, 2018 20:16
-
-
Save omiq/60df574fb3f9d8ddaab0a8a6bc8615e8 to your computer and use it in GitHub Desktop.
How to Automagically Create Thumbnail Images Using Python
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
import glob | |
from PIL import Image | |
# get all the jpg files from the current folder | |
for infile in glob.glob("*.jpg"): | |
im = Image.open(infile) | |
# convert to thumbnail image | |
im.thumbnail((128, 128), Image.ANTIALIAS) | |
# don't save if thumbnail already exists | |
if infile[0:2] != "T_": | |
# prefix thumbnail file with T_ | |
im.save("T_" + infile, "JPEG") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment