Skip to content

Instantly share code, notes, and snippets.

@hamzakat
Last active January 8, 2022 05:26
Show Gist options
  • Save hamzakat/02c023568ef905b8bce95ea902c15f2e to your computer and use it in GitHub Desktop.
Save hamzakat/02c023568ef905b8bce95ea902c15f2e to your computer and use it in GitHub Desktop.
Python3 script for converting TIFF images to JPEG
#!/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