Member-only story
Convert an Image to a PDF file using Python
Sep 16, 2024
pip install img2pdf
import img2pdf
# Open the image file in binary mode
with open("TVH.png", "rb") as image:
pdf_bytes = img2pdf.convert(image.read())
with open("TVH.pdf", "wb") as pdf:
pdf.write(pdf_bytes)
print("Image has been converted to PDF successfully.")
#source code --> clcoding.com
Image has been converted to PDF successfully