Replies: 2 comments 5 replies
-
Converted your post to a Discussion item right away - clearly not an issue.
In your case, bullet point 1 obviously happens. So you should be given the original image. How to convert this animal to a different image format (namely RGB) without resampling is a question that I cannot answer and which is outside PyMuPDF's scope. If you use the second method, you will get a Pixmap in CMYK format alright, then you can convert it to RGB by creating another pixmap, naming a different (i.e. RGB) colorspace: pix1 = fitz.Pixmap(doc, xref)
pix2 = fitz.Pixmap(fitz.csRGB, pix1) Same thing happens using this approach: img = doc.extract_image(xref)
pix1 = fitz.Pixmap(img["image"]) # detects format from passed in bytes
pix2 = fitz.Pixmap(fitz.csRGB, pix1) Of course you can also use packages like Pillow to make an image from the bytes object |
Beta Was this translation helpful? Give feedback.
-
You can look at the PDF xref of the image and |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is more likely my lack of understanding than an issue:
I have a .pdf with a CMYK image, and want an RGB.png with no resampling.
Is there a recipe for that ?
Following https://pymupdf.readthedocs.io/en/latest/document.html#Document.extract_image
(The top answer to SO extract-images-from-pdf-without-resampling-in-python
version for fitz 1.19.6 calls
extract_image
but doesn't use it ?!My pdf is pretty big to post, is there a small testcase ?
Thanks,
cheers
Beta Was this translation helpful? Give feedback.
All reactions