I'm trying to convert all files from a directory from .jpg to .png. The name should remain the same, just the format would change.
I've been doing some researches and came to this:
from PIL import Image
import osdirectory = r'D:\PATH'for filename in os.listdir(directory):if filename.endswith(".jpg"):im = Image.open(filename)im.save('img11.png')print(os.path.join(directory, filename))continueelse:continue
I was expecting the loop to go through all my .jpg files and convert them to .png files. So far I was doing only with 1 name: 'img11.png', I haven't succed to build something able to write the adequate names.
The print(os.path.join(directory, filename))
works, it prints all my files but concerning the converting part, it only works for 1 file.
Do you guys have any idea for helping me going through the process?