Sep-07-2017, 02:59 AM
I want to make a lot of student photos smaller, then paste them into an excel sheet. picSize is 300 pixel or 1"
I have almost got the resizing working, but I get this error:
Any tips please?
Resizing 刘洁.jpg...
changing image size...
Traceback (most recent call last):
File "<pyshell#107>", line 19, in <module>
im.save(resizedFilesDir, filename)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1669, in save
save_handler = SAVE[format.upper()]
KeyError: '刘洁.JPG'
I have almost got the resizing working, but I get this error:
Quote:Traceback (most recent call last):
File "<pyshell#107>", line 19, in <module>
im.save(resizedFilesDir, filename)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1669, in save
save_handler = SAVE[format.upper()]
KeyError: '刘洁.JPG'
Any tips please?
for filename in os.listdir(pathToFile): if not (filename.endswith('.png') or filename.endswith('.jpg')): continue im = Image.open(filename) width, height = im.size if width > picSize and height > picSize : # Calculate the new width and height to resize to. if width > height: height = int(picSize / width * height) width = picSize else: width = int(picSize / height * width) height = picSize # Resize the image. print('Resizing %s...' % (filename)) im = im.resize((width, height)) print('changing image size...') # Save changes. im.save(resizedFilesDir, filename)
Resizing 刘洁.jpg...
changing image size...
Traceback (most recent call last):
File "<pyshell#107>", line 19, in <module>
im.save(resizedFilesDir, filename)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1669, in save
save_handler = SAVE[format.upper()]
KeyError: '刘洁.JPG'