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

Pixmap created from CMYK JPEG delivers RGB format #3058

Closed
JorjMcKie opened this issue Jan 18, 2024 Discussed in #3057 · 2 comments
Closed

Pixmap created from CMYK JPEG delivers RGB format #3058

JorjMcKie opened this issue Jan 18, 2024 Discussed in #3057 · 2 comments

Comments

@JorjMcKie
Copy link
Collaborator

Discussed in #3057

Originally posted by dothinking January 18, 2024
With upgrading PyMuPDF from 1.23.8 to 1.23.15, fitz.Pixmap() doesn't work as expected. Do I miss something, or if it's an upstream issue.

sample.pdf

PyMuPdf 1.23.8

>>> import fitz
>>> fitz.version
('1.23.8', '1.23.7', '20231219000001')
>>> doc = fitz.Document('sample.pdf')
>>> doc[0].get_images(full=True)
[(17, 0, 1731, 1331, 8, 'DeviceCMYK', '', 'Im0', 'DCTDecode', 0)]
>>> pix = fitz.Pixmap(doc, 17)
>>> pix.colorspace
Colorspace(CS_CMYK) - DeviceCMYK
>>> pix = fitz.Pixmap(fitz.csRGB, pix)
>>> pix.save('sample-1.png')                      <- perfect

PyMuPdf 1.23.15

>>> import fitz
>>> fitz.version
('1.23.15', '1.23.9', '20240116000001')
>>> doc = fitz.Document('sample.pdf')
>>> doc[0].get_images(full=True)
[(17, 0, 1731, 1331, 8, 'DeviceCMYK', '', 'Im0', 'DCTDecode', 0)]    <- color space = DeviceCMYK
>>> pix = fitz.Pixmap(doc, 17)
>>> pix.colorspace
Colorspace(CS_RGB) - DeviceRGB                     <- color space seems changed to DeviceRGB
>>> pix = fitz.Pixmap(fitz.csRGB, pix)
>>> pix.save('sample-2.png')                   <- the png color is different from the source
```</div>
@JorjMcKie JorjMcKie changed the title Pixmap creation from CMYK JPEG creates RGB format Pixmap created from CMYK JPEG delivers RGB format Jan 18, 2024
julian-smith-artifex-com added a commit that referenced this issue Jan 18, 2024
Constructor `Pixmap(colorspace, pixmap)` previously always incorrectly
converted via a greyscale proofing colorspace.

Fixed similar bug in `Page.insert_image()` if we process the pixmap.

Also fixed creation of `Colorspace` from a `mupdf.FzColorspace` - this would
previously always created a RGB `Colorspace`.

Address #3058
@julian-smith-artifex-com
Copy link
Collaborator

Thanks for the report and for including the reproducer.

I have a fix in review, and will hopefully make a new release with the fix later today.

julian-smith-artifex-com added a commit that referenced this issue Jan 18, 2024
Constructor `Pixmap(colorspace, pixmap)` previously always incorrectly
converted via a greyscale proofing colorspace.

Fixed similar bug in `Page.insert_image()` if we process the pixmap.

Also fixed creation of `Colorspace` from a `mupdf.FzColorspace` - this would
previously always created a RGB `Colorspace`.

Address #3058
@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.23.16.

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