Issue with images opacity in PDF

18 views
Skip to first unread message

Cosmin Titiliuc

unread,
Apr 15, 2021, 5:27:23 AMApr 15
to skia-discuss
Hi all,

We are using skia in our application for writing PDFs and there seems to be an issue when adding images with opacity.
When opening the pdf in Chrome the opacity of the images looks fine. However, when opening it in Acrobat, Safari or Firefox images have much smaller opacity. It seems like the opacity is applied twice.

Using Acrobat Reader and preflight you can actually see that the transparency gets added (and applied) twice. Once on the image itself and once on the graphic object. A 0.8 opacity therefore results looking like a 0.64 opacity in the pdf.Screenshot 2021-04-14 at 21.44.18.png


I've created this simple fiddle: https://fiddle.skia.org/c/be7c61be9475b31dd1aa41a1a221046e. If you click on PDF and download it, you will end up with a PDF that showcases the issue. It will look good in Chrome, but not in other tools.

I also wrote this fiddle that goes through the whole pdf generation flow: https://fiddle.skia.org/c/b84e4329d2c04d785c05b701463e4bf1.

Is this a known issue? Should I file a bug for this?

Thanks!
Cosmin T.

Mike Reed

unread,
Apr 15, 2021, 9:21:30 AMApr 15
to skia-d...@googlegroups.com
You create a PDF with alpha = 0.8
When viewed in Chrome, it appears as 0.8, but when viewed in Acrobat / Safari / Firefox, it appears as 0.64

Is that correct?

It seems to me that this is a viewer problem/inconsistency, not a writer/skia issue: either Chrome's viewer or the other viewers are interpreting the PDF incorrectly, given that it is the identical PDF provided in each case. Is that correct?


--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/f900783e-cd6c-498e-ab39-0eaa46c9205cn%40googlegroups.com.

Cosmin Titiliuc

unread,
Apr 15, 2021, 9:47:30 AMApr 15
to skia-discuss
This is not a viewer problem/inconsistency. Adobe Acrobat and the other tools interpret the pdf correctly. The PDF that Skia writes is incorrect. It applies the transparency both on the image and the graphics object. This is why it gets multiplied. Both transparencies can be seen in the screenshot of the pdf's structure in the first post.
The fact that Chrome somehow interprets only one of the opacities is another bug or a workaround for this issue.

Group 1.png

Mike Reed

unread,
Apr 15, 2021, 9:57:16 AMApr 15
to skia-d...@googlegroups.com
"This is not a viewer problem/inconsistency"

Sounds like it is two bugs: chrome's viewer, and that skia is writing the PDF to produce double alpha. Gotcha.

Mike Reed

unread,
Apr 15, 2021, 9:58:50 AMApr 15
to skia-d...@googlegroups.com
so yes, if skia is producing a PDF that (when correctly viewed) double applies the intended alpha, then please create a bug/issue for that in skbug.com (your fiddle code seems like a great start).

Ben Wagner

unread,
Apr 15, 2021, 11:14:58 AMApr 15
to skia-d...@googlegroups.com
Definitely open an issue against Skia. This seems to be an issue localized to populate_graphic_state_entry_from_paint where the non-solid color shader case applies the paint alpha in the shader but then does not adjust the alpha of the path fill itself (the solid color case does adjust this). However, it will also be necessary to see if this continues to work in Pdfium and if it needs an issue as well.

Cosmin Titiliuc

unread,
Apr 15, 2021, 12:44:20 PMApr 15
to skia-discuss
Thanks everyone! Filed the following bug: https://bugs.chromium.org/p/skia/issues/detail?id=11863
Reply all
Reply to author
Forward
0 new messages