-
Notifications
You must be signed in to change notification settings - Fork 698
Open
Description
Description of the bug
Applying redactions with image cropping (images=pymupdf.PDF_REDACT_IMAGE_PIXELS) sometimes fail with the message only Gray, RGB, and CMYK colorspaces supported.
/usr/lib/python3.14/site-packages/pymupdf/__init__.py in ?(page, images, graphics, text)
10766
10767 if redact_annots == []: # any redactions on this page?
10768 return False # no redactions
10769
> 10770 rc = page._apply_redactions(text, images, graphics) # call MuPDF
10771 if not rc: # should not happen really
10772 raise ValueError("Error applying redactions.")
10773
/usr/lib/python3.14/site-packages/pymupdf/__init__.py in ?(self, text, images, graphics)
9925 opts.black_boxes = 0 # no black boxes
9926 opts.text = text # how to treat text
9927 opts.image_method = images # how to treat images
9928 opts.line_art = graphics # how to treat vector graphics
-> 9929 success = mupdf.pdf_redact_page(page.doc(), page, opts)
9930 return success
/usr/lib/python3.14/site-packages/mupdf/__init__.py in ?(doc, page, opts)
57660 def pdf_redact_page(doc, page, opts):
57661 r"""Class-aware wrapper for `::pdf_redact_page()`."""
> 57662 return _mupdf.pdf_redact_page(doc, page, opts)
FzErrorArgument: code=4: only Gray, RGB, and CMYK colorspaces supportedThe error message is unexpected but clear and workarounds exist, e.g., redacting the image with total removal (images=pymupdf.PDF_REDACT_IMAGE_REMOVE). Thus, feel free to classify it as feature request or close it. Thanks.
How to reproduce the bug
- Get sample from: https://github.com/ArtifexSoftware/tests/blob/master/pdf/foo0-ge-64k.pdf
- Run following python code snippet:
document = pymupdf.Document("foo0-ge-64k.pdf")
page = document[0]
page.add_redact_annot(page.rect)
page.apply_redactions(images=pymupdf.PDF_REDACT_IMAGE_PIXELS)PyMuPDF version
1.27.1
Operating system
Linux
Python version
3.14
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels