Created
May 16, 2015 02:09
-
-
Save artschwagerb/671210239aabede5593a to your computer and use it in GitHub Desktop.
PIL - Convert to bmp, and resize
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 | |
size = 145, 145 | |
dir_path = '/Users/brian/Desktop/systems_silly' | |
for filename in os.listdir(dir_path): | |
if filename.endswith('.bmp'): | |
# Destroy Previously Converted Bmp | |
try: | |
os.remove(os.path.join(dir_path,filename.replace('.jpg','.bmp'))) | |
except: | |
pass | |
elif filename.endswith('.jpg'): | |
# Quality Control | |
im = Image.open(os.path.join(dir_path, filename)) | |
#im.save(os.path.join(dir_path, filename), quality=-50) | |
# What if the world was black and white | |
im = im.convert(mode="P", palette=Image.ADAPTIVE, colors=256) | |
# To bmp | |
im = im.convert("RGB") | |
# Thumbnail | |
im.thumbnail(size) | |
# Print Shop Deluxe | |
im.save(os.path.join(dir_path,filename.replace('.jpg','.bmp'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment