from PIL import Image
# Load the PNG image
image = Image.open("image.png")
# Convert the image to RGB mode (if necessary)
if image.mode != "RGB":
image = image.convert("RGB")
# Set the output PDF filename
pdf_filename = "image.pdf"
# Convert the image to PDF and save it
image.save(pdf_filename, "PDF", resolution=100.0)