0

I have Jpg images which are in one folder. I want to replace that images with png format in the same folder and same name.how to do this? here what i tried:

image_path =''
input_image = Image.open(image_path).convert('RGB')
input_image.save(image_path + ".png", "PNG")
Jessica
  • 205
  • 2
  • 6
  • 14

1 Answers1

0

form a list of files with os.listdir() and iterate them with a for loop.

import os
image_path ='some_path/'
for img in os.listdir(image_path):
    input_image = Image.open(image_path+img).convert('RGB')
    input_image.save(image_path+img + ".png", "PNG")

Hope this helps! Cheers!

SanthoshSolomon
  • 1,383
  • 1
  • 14
  • 25