Simple python function to convert any kind of image file to PNG
def convertToPNG(input_webp_file, output_png_file):
from PIL import Image
try:
# Open the WebP image
with Image.open(input_webp_file) as img:
# Convert and save as PNG
img.save(output_png_file, 'PNG')
print(f"WebP image converted to PNG: {output_png_file}")
except Exception as e:
print(f"Error converting WebP to PNG: {e}")
Comments
Post a Comment