Skip to content

Instantly share code, notes, and snippets.

@BernardoGO

BernardoGO/resize.py

Created Apr 22, 2020
Embed
What would you like to do?
from PIL import Image
from glob import glob
import shutil
import random
import os
files = glob("500x500/*/*")
outputPath = "output3/"
newSize = [400, 400]
for x in files:
dirname = os.path.dirname(x)
img=Image.open(x)
new_img=img.resize((newSize[0],newSize[1]))
os.makedirs(outputPath+x.split("/")[-2]+"/", exist_ok=True)
new_img.save(outputPath+x.split("/")[-2]+"/"+os.path.basename(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment