I am trying to convert all my images in a file into jpg format, defined as 'a' but I keep getting error as cannot convert. Any help?
from PIL import Image
import matplotlib.pyplot as plt
import os
#import imtools
#path = imtools.get_imlist('.')
a = 'K:\wq'
for infile in os.listdir(a):
outfile = os.path.splitext(infile)[0] + ".jpg"
if infile != outfile:
try:
Image.open(infile).save(outfile)
except OSError as error:
print ("cannot convert", infile)
error log: cannot convert manojcasual.png
Process finished with exit code 0