10000 JP2 failed to put in PDF correctly when handling color images · Issue #8980 · python-pillow/Pillow · GitHub
[go: up one dir, main page]

Skip to content

JP2 failed to put in PDF correctly when handling color images #8980

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

Closed
Sissel-Ng opened this issue May 27, 2025 · 2 comments
Closed

JP2 failed to put in PDF correctly when handling color images #8980

Sissel-Ng opened this issue May 27, 2025 · 2 comments

Comments

@Sissel-Ng
Copy link

What did you do?

Changing colour JP2 images from Library of Congress to PDF format.

What did you expect to happen?

Simply format change and should expect a properly showed colour pdf.

What actually happened?

Decoding faulted and resulted in overlaying pdf.

What are your OS, Python and Pillow versions?

  • OS: Pop!_OS 22.04 LTS
  • Python: 3.12.10
  • Pillow: 11.2.1
--------------------------------------------------------------------
Pillow 11.2.1
Python 3.12.10 (main, Apr 28 2025, 18:36:47) [GCC 11.4.0]
--------------------------------------------------------------------
Python executable is /usr/local/bin/python3
System Python files loaded from /usr/local
--------------------------------------------------------------------
Python Pillow modules loaded from /home/mnsis/.local/lib/python3.12/site-packages/PIL
Binary Pillow modules loaded from /home/mnsis/.local/lib/python3.12/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.2.1
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.5.0
*** AVIF support not installed
--- JPEG support ok, compiled for libjpeg-turbo 3.1.0
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.3
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.11, compiled for zlib-ng 2.2.4
--- LIBTIFF support ok, loaded 4.7.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.8, harfbuzz 11.0.1
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------

Image

The original image:

Barcarolle-0001.zip

The result file cannot be uploaded as GitHub does not allow me uploading that large of a file.
Here is a screenshot:

Image

Notice that this only affects colour images. Grayscale and B/W works out just fine without any distortions.

@radarhere radarhere changed the title JP2 failed to put in PDF correctly when handling color images. JP2 failed to put in PDF correctly when handling color images May 27, 2025
@radarhere
Copy link
Member
radarhere commented May 27, 2025

When I use Pillow to resave your image as a PDF, here is the resulting file that I get - sam.pdf

When I view the PDF, I don't see a problem. The image that you provided is in RGBA mode. This makes me think this is a recurrence of #8074, where Pillow was creating a well-formed PDF, but there is a bug in the viewer that prevents it from displaying it correctly.

What program are you using to view the PDF? What version of that software are you using?

If you view your PDF in a browser, does it display correctly?

If you are looking for a workaround, I expect converting the image to RGB will work.

from PIL import Image
l = [Image.open(f"Barcarolle-000{p}.jp2") for p in range(1, 7)]
l[0].convert("RGB").save("sam.pdf", "PDF")

@Sissel-Ng
Copy link
Author

Okay, I checked the program, and it is indeed envice (packaged in Pop!OS, GNOME 42.9).

And it is totally fine in browser, yes. The workaround is also working. Thanks you for solving this!

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
0