Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding multiple images to PDF #2511

Closed
thinrhino opened this issue May 9, 2017 · 3 comments
Closed

adding multiple images to PDF #2511

thinrhino opened this issue May 9, 2017 · 3 comments

Comments

@thinrhino
Copy link

thinrhino commented May 9, 2017

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])
@thinrhino
Copy link
Author

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? :-)

@radarhere
Copy link
Member

radarhere commented May 13, 2017

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.

@radarhere
Copy link
Member

This feature has now been added to Pillow, and will be part of the 4.2 release on July 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants