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

Missing ICC colorspaces lead to unsatisfactory color renderings #397

Closed
dalanicolai opened this issue Nov 9, 2019 · 14 comments
Closed

Missing ICC colorspaces lead to unsatisfactory color renderings #397

dalanicolai opened this issue Nov 9, 2019 · 14 comments
Assignees
Labels
bug postpone postpone to a future version

Comments

@dalanicolai
Copy link

dalanicolai commented Nov 9, 2019

Converting an pdf to a different format using pymupdf, e.g. writeImage() for pixmap or getSVGimage() for page, results in quite strong deviating colors as when converting with e.g. 'mutool draw' or the 'gs -sDEVICE=pngalpha' command from the command line.

To see what I mean just open this example pdf file in any of the pymupdf based viewers found here and compare the resulting colors to the colors when the same file is opened in any other pdf-viewer.

The deviation is introduced when converting the pdf-file to a different format (as explained above) using pymupdf. It seems that the problem is not mupdf related as converting the pdf-file using 'mutool draw' on the command line results in 'correct' colors.

To conversion with pymupdf result in much too bright colors, while the mutool gives 'good/pleasant' color as shown in the following screenshots:

pymupdf
pymupdf (above)
mutool (below)
mutool

  • Operating system: fedora 31, 64-bit (GCC 9.2.1 20190827 (Red Hat 9.2.1-1))
  • Python version: 3.7.5 64-bit
  • PyMuPDF version: 1.16.6, installed with pip3
@JorjMcKie
Copy link
Collaborator

Confirming your observation. Thanks for submitting this.

Your example uses so-called "color separation" which I have not yet implemented in PyMuPDF, although MuPDF does support this.

Let me check how to integrate this. Any urgency?

@dalanicolai
Copy link
Author

dalanicolai commented Nov 10, 2019 via email

@JorjMcKie
Copy link
Collaborator

Thanks for the compliments!
You are aware that PyMuPDF supports annotations (for PDF only)?
There also is a general document browser based on tkinter using the PySimplGUI repo.
"General" here means, that all MuPDF document types are supported - not just PDFs.
When creating pixmaps, you can choose to suppress annotations, and annotations themselves support creation of individual pixmaps.
You may also be interested having a look at SumatraPDF, a (regrettably Windows-only) document viewer, which is based on MuPDF, but also has an extended document support: more e-book formats, Windows CHM help files, ...

@dalanicolai
Copy link
Author

dalanicolai commented Nov 10, 2019 via email

@JorjMcKie
Copy link
Collaborator

I was on the wrong track:
It is not missing separations support which cause this effect, but missing support of so-called ICC colorspaces.
I ony recently removed this support because it has caused issues in some other cases.
To re-activate this support, MuPDF must re-generated with a changed configuration.

@JorjMcKie
Copy link
Collaborator

Confirming my previous post:
Including ICC support in MuPDF (again) solves your issue.

@JorjMcKie JorjMcKie changed the title Colors from 'format' conversion with pymupdf strongly deviate from e.g. conversion with mutool Missing ICC colorspaces lead to unsatisfactory color renderings Nov 11, 2019
@dalanicolai
Copy link
Author

dalanicolai commented Nov 11, 2019 via email

@JorjMcKie
Copy link
Collaborator

I am undecided how to handle this.
For the time being, I could "privately" send you a wheel if you tell me all your software "coordinates".
I want to look look up the other issue with ICC problem again attack it in a way which lets me stay with ICC support included. Just don't know how long this would take me.

@JorjMcKie
Copy link
Collaborator

I found issue #188 which states that kicking ICC out of PyMuPDF only has advantages ...
You are living proof, that I was wrong then 🙄
So I believe I will just reactivate ICC in version 1.16.8.

@JorjMcKie
Copy link
Collaborator

Was too fast: issue #369 reported a serious problem with ICC colorspaces.
So I will investigate this case again, before I try to make a decision.

@dalanicolai
Copy link
Author

dalanicolai commented Nov 12, 2019 via email

@JorjMcKie
Copy link
Collaborator

JorjMcKie commented Mar 9, 2020

@dalanicolai - hope it's good news:
The next PyMuPDF version (1.16.12) will allow switching ICC support on or off programmatically. Per default, ICC is enabled.
This can be changed at any time using statement

fitz.TOOLS.set_icc(False)  # or True to enable it again.

Accordingly, I will close this issue upon publishing this version.

@dalanicolai
Copy link
Author

dalanicolai commented Mar 10, 2020 via email

@JorjMcKie
Copy link
Collaborator

Official version 1.16.12 just published.

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

No branches or pull requests

2 participants