Last active
January 8, 2022 05:26
-
-
Save hamzakat/02c023568ef905b8bce95ea902c15f2e to your computer and use it in GitHub Desktop.
Python3 script for converting TIFF images to JPEG
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
#!/usr/bin/python3 | |
# Python3 script for converting TIFF images to JPEG | |
from PIL import Image | |
import os | |
imgs_dir = "images" | |
files = os.listdir(imgs_dir) | |
for img_file in files: | |
img_path = os.path.join(imgs_dir, img_file) | |
if os.path.isfile(img_path): | |
old_img = Image.open(img_path) | |
new_img = old_img.rotate(90).resize((128,128)).convert('RGB') | |
outfile_name = img_file + ".jpg" | |
new_img.save(outfile_name, "JPEG", quality=90) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment