Pixmap not taking /Decode value into account when dealing with /ImageMask images #1192
Replies: 2 comments
-
This error is happening inside the MuPDF code - which cannot be fixed inside PyMuPDF. If you need to find a way out urgently, use code based on this, which uses Pillow to (hopefully) correctly deal with this. |
Beta Was this translation helpful? Give feedback.
-
Encapsulate code lines inside lines 3 |
Beta Was this translation helpful? Give feedback.
-
Please provide all mandatory information!
Describe the bug (mandatory)
I encountered it on a document that had the /Decode value set to [ 1 0 ] instead of the default [ 0 1 ]. After saving the image, it was white on black, but in document it is black on white.
To Reproduce (mandatory)
Snippet:
pdf_file = fitz.open(self.file_path)
for page in pdf_file:
images = pdf_file.get_page_images(page)
for image in images:
pix = fitz.Pixmap(pdf_file, image[0])
pix.invert_irect(pix.irect)
pix.writePNG(image_file_path)
The file in question is sensitive, so I'd rather not send it publicly. I can provide it by request through secure channels.
Not sure about the indentation, is there a way to make it work in this context?
Expected behavior (optional)
Describe what you expected to happen (if not obvious).
Screenshots (optional)
If applicable, add screenshots to help explain your problem.
Your configuration (mandatory)
For example, the output of
print(sys.version, "\n", sys.platform, "\n", fitz.__doc__)
would be sufficient (for the first two bullets).Additional context (optional)
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions