I am trying to add multiple pages in PDF, but for some reason it is not working.
As per the documentation, save_all=True, should work. What am I missing or is this a bug?
import PIL
print(PIL.__version__)
4.1.1
from PIL import Image
a4im = Image.new('RGB',
(1654, 2338),
(255, 255, 255))
a4im2 = Image.new('RGB',
(1654, 2338),
(255, 255, 255))
img = Image.open("image_1.jpg")
img = img.convert('RGB')
img = img.resize((1600, 720))
a4im.paste(img, (27,10))
img_2 = Image.open("image_2.jpg")
img_2 = img_2.convert('RGB')
img = img.resize((1600, 720))
a4im2.paste(img_2, (27, 10))
a4im.save("out.pdf", save_all=True, append_images=[a4im2])
While going through the test_file_pdf.py, I realised that, I can first make a GIF image with multiple frames and then, save the document to pdf!
Now my question: Is this is a hack or is this the intended behaviour? :-)
append_images is currently only supported for GIF - http://pillow.readthedocs.io/en/4.1.x/releasenotes/3.4.0.html#append-images-to-gif, http://pillow.readthedocs.io/en/4.1.x/handbook/image-file-formats.html?highlight=image%20file%20formats#saving
I have created a PR to add this feature for PDF, so it may exist in a future version of Pillow.
This feature has now been added to Pillow, and will be part of the 4.2 release on July 1.
Most helpful comment
This feature has now been added to Pillow, and will be part of the 4.2 release on July 1.