Skip to content

Instantly share code, notes, and snippets.

@giasuddin90
Created October 30, 2019 11:00
Show Gist options
  • Select an option

  • Save giasuddin90/f09407183bb4edce468cbb7705a909e7 to your computer and use it in GitHub Desktop.

Select an option

Save giasuddin90/f09407183bb4edce468cbb7705a909e7 to your computer and use it in GitHub Desktop.
Python image file resize using pill library
__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