Request for PDF Layer Color Space Information and Document Color Space Detection in PyMuPDF #3829
Unanswered
Danishkhilji
asked this question in
Looking for help
Replies: 1 comment 1 reply
-
What PDF informally calls "Layers" are really "Optional Content Groups". Optional Content Groups don't have color information associated with them. Yes, it may be that everything in a given Optional Content group might happen to use the same color model, but there is nothing requiring that. It's perfectly possible to have content in a group that comes from multiple different sources, each with a different color model. So I'm not sure exactly what you'd want us to return. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
I am working with PyMuPDF and seeking a way to retrieve detailed color space information for individual layers within a PDF. Currently, using doc.get_ocgs(), I can access basic details about each layer (e.g., name, visibility status, usage) but not the color space information.
Current Approach::
I am working with PyMuPDF and seeking a way to retrieve detailed color space information for individual layers within a PDF. Currently, using doc.get_ocgs(), I can access basic details about each layer (e.g., name, visibility status, usage) but not the color space information.
Current Approach
I have accessed layer information with the following code:
layers = doc.get_ocgs() for layer_item in layers.items(): print(f"Layer: {layer_item}")
The output provides details like:
Layer Information: Layer: (10, {'name': 'Artwork', 'intent': ['View', 'Design'], 'on': True, 'usage': 'Artwork'}) Layer: (7, {'name': 'Keylines', 'intent': ['View', 'Design'], 'on': False, 'usage': 'Artwork'}) Layer: (8, {'name': 'White', 'intent': ['View', 'Design'], 'on': False, 'usage': 'Artwork'}) Layer: (9, {'name': 'Guideline', 'intent': ['View', 'Design'], 'on': False, 'usage': 'Artwork'})
However, there is no information about the color space for these layers.
Objective
Retrieve Layer Color Space: Is there a way to directly get color space information for individual layers using PyMuPDF?
Document Color Space Detection: If direct retrieval is not possible, can we infer the document’s color space based on layer visibility? For example, could we analyze the document by turning off all layers and examining the resulting color information?
Additional Details
I am specifically interested in knowing whether a layer uses CMYK, RGB, or another color space.
Any potential workarounds or alternative methods for detecting color space based on layer visibility would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions