-
Notifications
You must be signed in to change notification settings - Fork 681
How to recognise transparent images? #1226
-
Using OpenPDF library I can scan through document objects, see images and even extract these images. However, I have not found a way to check if an image is transparent. The information is not within an individual image but rather in relationship of two images or layers I assume. But how to check this out?
I don't need to flatten transparency (I know there are tools for it), just identifying is enough. The big picture is about printing a PDF and there transparent images are not supported by the service provider. I'm trying to identify PDF documents containing transparent images and reject printing.
Any hint appreciated
Beta Was this translation helpful? Give feedback.
All reactions
When you inspect the objects a PDF consists of, you should have a copy of the current specification at your hand, ISO 32000-2. You can get a free copy at the PDF association, see https://www.pdfa-inc.org/product/iso-32000-2-pdf-2-0-bundle-sponsored-access/
In section 8.9.5 you'll find the image dictionaries explained. In particular the entries ImageMask, Mask, and SMask. Beware, though, transparency can also be achieved for regions of a PDF page which by chance may contain images, e g. by clip paths and general graphics state SMasks.
Replies: 1 comment 1 reply
-
When you inspect the objects a PDF consists of, you should have a copy of the current specification at your hand, ISO 32000-2. You can get a free copy at the PDF association, see https://www.pdfa-inc.org/product/iso-32000-2-pdf-2-0-bundle-sponsored-access/
In section 8.9.5 you'll find the image dictionaries explained. In particular the entries ImageMask, Mask, and SMask. Beware, though, transparency can also be achieved for regions of a PDF page which by chance may contain images, e g. by clip paths and general graphics state SMasks.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks, that led me to the right direction. Eventually I did very rudimentary test: if image has a mask, then it is part of transparency. Probably not 100% accurate but serves my purpose and worked with few test cases.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1