Skip to content

Cannot save PDF with mode RGBA #6924

@pubpub-zz

Description

@pubpub-zz

What did you do?

from PIL import Image
p=Image.open("e:/Downloads/pillow_putalpha_circle_blur.jp2")
p.save("e:/Downloads/pillow_putalpha_circle_blur.pdf")

test file
pillow_putalpha_circle_blur.zip

What did you expect to happen?

PDF with RGBA image encoded with JPXDecode filter

What actually happened?

Traceback (most recent call last):
  File "<pyshell#268>", line 1, in <module>
    p.save("e:/Downloads/pillow_putalpha_circle_blur.pdf")
  File "C:\Python310\lib\site-packages\PIL\Image.py", line 2300, in save
    save_handler(self, fp, filename)
  File "C:\Python310\lib\site-packages\PIL\PdfImagePlugin.py", line 155, in _save
    raise ValueError(f"cannot save mode {im.mode}")
ValueError: cannot save mode RGBA

What are your OS, Python and Pillow versions?

  • OS: windows 11
  • Python: 3.10.4
  • Pillow: 9.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions