Mar-02-2022, 06:35 PM
Greetings,
I can't get a Python PIL script to run, get "not an image" error.
Appreciate any pointers, to resolve this.
The code is:
C:\Users\u00\inspection_images\101MEDIA_11-18-21\100_20-0653.jpg
C:\Users\u00\inspection_images\101MEDIA_11-18-21\100_20-0654.jpg
C:\Users\u00\inspection_images\101MEDIA_11-18-21\100_20-0655.jpg
The output (2) are:
I can't get a Python PIL script to run, get "not an image" error.
Appreciate any pointers, to resolve this.
The code is:
for (root, dirs, files) in os.walk(img_path): for name in files: img = (os.path.join(root,name)) print(img) try: #print(' "%s" ' % img) ### "'%s'" % #img = (img) << 1 image = Image.open(img) ### images are color images print(image) << 2 #MAX_SIZE = (224,224) #image.thumbnail(MAX_SIZE) #thumb = image.resize((224,224), Image.ANTIALIAS) #image.save(copy_path,name) #print() except: print("not an image")The files (1) are:
C:\Users\u00\inspection_images\101MEDIA_11-18-21\100_20-0653.jpg
C:\Users\u00\inspection_images\101MEDIA_11-18-21\100_20-0654.jpg
C:\Users\u00\inspection_images\101MEDIA_11-18-21\100_20-0655.jpg
The output (2) are:
Output:<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=224x224 at 0x419DA90>
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=224x224 at 0x419D700>
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=224x224 at 0x419D0D0>