We are installing Pillow forked from PIL (as it is compatible with setuptools)
pip install pillow
- Navigate to any folder contains images of type JPEG
- Download by Right-click and
save as
resize_image.py
OR
You can create new python file and paste the code
from PIL import Image
import glob, os
size = 250, 250 # 250 by 250 square sized
directory = 'thumbnails'
for infile in glob.glob("*.jpg"):
print infile
if not os.path.exists(directory):
os.makedirs(directory)
file, ext = os.path.splitext(infile)
im = Image.open(infile)
im.thumbnail(size)
im.save(directory + '/' + file + "-thumbnail.jpg", "JPEG")
print "Your thumbnails are saved inside thumbnails folder"
- Naviage to the location where
resize_image.py
lives in terminal and run python resize_image.py
Navigate to the thumnails folder and check the resized images