Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
619 B
0
Indexable
Never
from PIL import Image

def convert_jpg_to_png(input_path, output_path):
    try:
        # Open the JPG image
        image = Image.open(input_path)

        # Convert and save as PNG
        image.save(output_path, 'PNG')

        print(f"Conversion successful. Image saved as {output_path}")
    except Exception as e:
        print(f"An error occurred: {e}")

def main():
    input_file = 'input.jpg'   # Replace with the path to your JPG image
    output_file = 'output.png'  # Replace with the desired path for the PNG output

    convert_jpg_to_png(input_file, output_file)

if __name__ == "__main__":
    main()