Gray outlines around edges of transparent areas in embedded raster images
This issue is best illustrated with an example.
I generated a 5x5 png test image with transparent background and a 1 pixel wide green strip through the middle, embedded it into an svg, converted it to a pdf using inkscape and then rendered it at 2000 dpi on a white background using the C++ interface of poppler 21.01. The result can be seen here:
Notice how the green band fades first to gray, then to white, instead of fading directly to white. (The green band is also off-center, which is a separate issue.) The same pdf file rendered with PDF.js looks like one would expect, as seen here:
The gray border goes away if the original png has a white background instead of a transparent background. Here are the input png, svg and pdf for this case, and the render looks like this:
This test case is of course a bit contrived, but this behavior has real-world consequences. For example, a pdf figure that includes a raster contour plot with lots of thin colored curves on transparent background, will appear desaturated, especially as one zooms out.
I see the same behavior in acrobat reader too, and I hear that the chrome pdf reader also has this behavior. The only renderer I have seen with the expected behavior was PDF.js. So maybe that's the buggy one and the gray borders are expected? I hope not, as the PDF.js output is the only one that looks sensible. To check that it wasn't an inkscape bug I also tried converting the svg (which renders correctly in all the cases) to pdf using rsvg-convert too, but this did not change anything.
My guess is that the transparent pixels have a black (but invisible) color, and that the interpolation formula uncritically interpolates R, G, B and A between #00ff00ff and #00000000, resulting in intermediates like #00800080, which when alpha composited with white gives #80c080, a slightly green shade of gray. To avoid this happening, I think one would need to alpha-composite before interpolation instead of after.