Last active
May 14, 2020 01:49
-
-
Save AVJdataminer/600b6d2baa35d3a642f9fa3603048f34 to your computer and use it in GitHub Desktop.
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 PIL | |
from PIL import Image | |
import os | |
import sys | |
path = "/path/to/file" | |
dirs = [file for file in os.listdir(path) if file.endswith('.png')] | |
#pixelsize = 500; | |
def resize_thumbnail(): | |
for item in dirs: | |
if os.path.isfile(path+item): | |
image = Image.open(path+item) | |
file_path, extension = os.path.splitext(path+item) | |
image = Image.open(path+item) | |
image.thumbnail((500,500), Image.ANTIALIAS) | |
if image.mode in ("RGBA", "P"): | |
image = image.convert("RGB") | |
image.save(file_path + "_thumb.jpg" ,'JPEG', quality=90) | |
resize_thumbnail() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment