#pip install img2pdf import img2pdf with open("name.pdf","wb") as f: f.write(img2pdf.convert(['a.png','b.png']))