


Image_path = os.path.join(mypath,each_file)

Mypath = "\Images" # path to your Image directory It's is a Python wrapper for for ImageMagick (or GraphicsMagick). Pgmagick is a GraphicsMagick(Magick++) binding for Python. Note:Install the newest PIL to make sure save_all argument is available for PDF.Īpply this fix png = Image.open('/path/to/your/file.png')īackground = Image.new("RGB", png.size, (255, 255, 255))īackground.paste(png, mask=png.split()) # 3 is the alpha channel The solution is here Error while saving multiple JPEGs as a multi-page PDF You might encounter the AttributeError: 'JpegImageFile' object has no attribute 'encoderinfo'. Just set save_all to True and append_images to the list of images which you want to add. Pdf_path, "PDF" ,resolution=100.0, save_all=True, append_images=images Pdf_path = "/Users/apple/Desktop/bbd1.pdf" It's quite simple yet powerful: from PIL import Image # install by > python3 -m pip install -upgrade Pillow # ref. The best method to convert multiple images to PDF I have tried so far is to use PIL purely.
