from PIL import Image import shutil import os, sys basewidth = 1600 def compress(filename, destfilename, quality_num, cropsize = (), whitebg = False): # Make PNG Background White if whitebg: fill_color = (255,255,255) im = Image.open(filename) im = im.convert('RGBA') background = Image.new(im.mode[:-1], im.size, fill_color) background.paste(im, im.split()[-1]) # omit transparency original = background else: original = Image.open(filename) # Check PNG Images with no Trasperant Data if filename.endswith(".png"): original = original.convert('RGBA') datas = original....
Resize
