#!/usr/bin/python
from PIL import Image
import os, sys
path = "C:/Users/nonono/Desktop/hypergan/data/trainingData/"
dirs = os.listdir( path )
def resize():
for item in dirs:
if os.path.isfile(path+item):
im = Image.open(path+item)
f, e = os.path.splitext(path+item)
imResize = im.resize((256,256), Image.ANTIALIAS)
imResize.save(f + ' resized.jpg', 'JPEG', quality=90)
resize()
i got this code from another answer here and fitted it to my own parameters, yet when i run it in the command line i get an error:
Traceback (most recent call last):
File "resize.py", line 16, in <module>
resize()
File "resize.py", line 11, in resize
im = Image.open(path+item)
File "C:\Users\nonono\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py", line 2822, in open
raise IOError("cannot identify image file %r" % (filename if filename else fp))
OSError: cannot identify image file 'C:/Users/nonono/Desktop/hypergan/data/trainingData/bx71zze7egy18wel231 resized.jpg'
the folder trainingData
is filled with a large amount of images, that i want to resize to 256x256 regardless of aspect ratio, i will not need the images afterwards so if there is a way to replace the images instead of just copying, resizing, and renaming, that would be great (unless i am reading this incorrectly, i have about 2 weeks experience in python)
any help would be appreciated