import img2pdf with open("output.pdf","wb") as f: with open("input.png","rb") as imgf: f.write(img2pdf.convert(imgf))