Created
May 17, 2015 00:54
-
-
Save artschwagerb/47ae62662ac3ae78aad7 to your computer and use it in GitHub Desktop.
Convert JPEG to BMP
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' | |
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'): | |
# Open Image | |
im = Image.open(os.path.join(dir_path, filename)) | |
# Quality Control | |
#im.save(os.path.join(dir_path, filename), quality=-50) | |
# What if the world had a set number of colors | |
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