Created
May 5, 2020 07:37
-
-
Save cawabunga/f5c0e37592deda5e789c1b46cc2e1529 to your computer and use it in GitHub Desktop.
Qwerty
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue May 5 00:38:34 2020 | |
@author: RIbatullin | |
""" | |
def squeeze(): | |
from tkinter.filedialog import askdirectory | |
import os | |
from PIL import Image | |
path = askdirectory(title='Select Folder') # shows dialog box and return the path | |
path2 = path + '//squeezed' | |
try: | |
os.mkdir(path2) | |
except OSError: | |
pass | |
for f in os.listdir(path): | |
if f.endswith(".JPG") or f.endswith(".JPEG"): | |
img = Image.open(path+'/'+ f) | |
new_img = img.resize((img.width,img.height//2)) | |
exif = img.info['exif'] | |
new_img.save(path2+'/'+f, 'JPEG', exif = exif) | |
if __name__=="__main__": | |
#import doctest | |
#doctest.testmod(verbose=False) | |
squeeze() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment