Skip to content

Instantly share code, notes, and snippets.

@BernardoGO
Created April 22, 2020 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BernardoGO/2451ae8e96f63ade0e2e627fd3a3936e to your computer and use it in GitHub Desktop.
Save BernardoGO/2451ae8e96f63ade0e2e627fd3a3936e to your computer and use it in GitHub Desktop.
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