Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
P
poppler
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 613
    • Issues 613
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 40
    • Merge Requests 40
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • poppler
  • poppler
  • Issues
  • #1032

Closed
Open
Opened Jan 22, 2021 by Sigurd Næss@sigurdkn

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:

test1_out.png

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:

test1_out_pdfjs.png

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:

test2_out.png

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.

Edited Jan 22, 2021 by Sigurd Næss
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: poppler/poppler#1032