Reputation: 1
I need to open images and edit them. But when opened, "no such file or directory" or "<ImagingCore object at 0x0000020625552F70>" comes out. The path is specified correctly, checked several times. How do I open the image correctly? Also how can I save an already edited image to another folder with the same name? '''
from PIL import Image
import os
def convertImage():
folder_dir = "C:\проект\Images"
for images in os.listdir(folder_dir):
img = Image.open(images)
img = img.convert("RGBA")
'''
Upvotes: 0
Views: 228
Reputation: 364
'No such file or directory' is caused by the path. It has backslashes, which is an escape character. So the correct way to define your path is:
folder_dir = "C:\\project\\Images"
To save the edited image you can use:
img.save('path/to/output/img')
Upvotes: 1