Created
October 30, 2019 11:00
-
-
Save giasuddin90/f09407183bb4edce468cbb7705a909e7 to your computer and use it in GitHub Desktop.
Python image file resize using pill library
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
| __author__ = 'giasuddin' | |
| from PIL import Image | |
| import os, sys | |
| size = (250, 500) | |
| path = "/home/giasuddin/script/imgresize/all" | |
| dirs = os.listdir(path) | |
| directory = '/home/giasuddin/script/imgresize/dr' | |
| # os.makedirs(directory) | |
| # filePath = os.path.abspath('IMG_3391.JPG') | |
| for item in dirs: | |
| if os.path.isfile(path + '/' + item): | |
| img = Image.open(path + '/' + item) | |
| # Resize it. | |
| img = img.resize(size, Image.BILINEAR) | |
| # Save it back to disk. | |
| img.save(os.path.join(directory, 'resized-' + item)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment