from PIL import Image # Open the JPG image file jpg_image = Image.open("example.jpg") # Convert the image to PNG format png_image = jpg_image.convert('RGBA') # Save the PNG image file png_image.save("example.png")