Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pil
#2
Please use correct tags when posting code.
This works for me

from os import walk
from PIL import Image

path = r'images'
copy_path = r'thumbs'
files = '*.png'
filename = []

for root, dir, files in walk(path):
    for img in files:
        try:
            image = Image.open(f'{path}/{img}')
            image.thumbnail((32,32))
            image.save(f'{copy_path}/thumb_{img}')
        except ValueError:
            print('Not a image')
BashBedlam likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
Pil - by Clives - Mar-02-2022, 06:35 PM
RE: Pil - by menator01 - Mar-02-2022, 07:57 PM
RE: Pil - by deanhystad - Mar-02-2022, 10:20 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020