Last active
August 9, 2018 22:02
-
-
Save aaronjolson/f8eef70a39f99829a417b521318f6d90 to your computer and use it in GitHub Desktop.
Converts all png, tif, and bmp files in a directory into jpegs
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 os | |
from PIL import Image | |
for infile in os.listdir("./"): | |
print ("file : " + infile) | |
if infile[-3:] == "tif" or infile[-3:] == "bmp" or infile[-3:] == "png": | |
outfile = infile[:-3] + "jpeg" | |
im = Image.open(infile) | |
print("new filename : " + outfile) | |
out = im.convert("RGB") | |
out.save(outfile, "JPEG", quality=90) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment