linebender / linebender/resvg

Visible banding in many images due to componding 8-bit precision loss

Open
#1,126 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

Gradients, blurs and other filters producing smooth color transitions often result in visible banding in RGBA8888, due to the limited precision of the format. But some parts of the internal resvg pipeline appear to compound these issues with repeated rounding. I've compiled a small torture test that demonstrates the issue and included it below. I have also submitted PRs for resvg and tiny-skia that introduce an optional 16bpc pipeline that largely eliminates the issue:

- https://github.com/linebender/tiny-skia/pull/188
- https://github.com/linebender/resvg/pull/1125

I realise that formats other than RGBA8888 are explicitly out of scope for tiny-skia, and the sheer size and AI-assisted origin of these PRs may make them seem like a hostile act! But I have tried to remain respectful of the design goals and performance of the existing 8bpc pipeline, and keep the binary as clean and performant as possible when the 16bpc pipeline is disabled.

This was mostly an itch I wanted to scratch, since there are currently very few tools to render a SVG file with end-to-end 16bpc precision so that RGBA8888 banding can be minimised via dithering. I'm not here to argue that the project scope should be changed to include it!

(all images below are designed to be viewed full size at native 1:1 resolution)

Torture test SVG (will be rendered by your browser's SVG engine):

Image

Torture test SVG rendered with resvg 8pbc pipeline:

Image

Torture test SVG rendered with resvg 16pbc pipeline and truncated to 8bpc - still has inherent RGBA8888 banding, but removes the compounded internal rounding:

Image

Torture test SVG rendered with resvg 16pbc pipeline and dithered to 8bpc, which trades RGBA8888 banding for dithering noise (which may be exacerbated if displayed at sizes other than 1:1):

Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the attached torture-test SVG and its rendered comparisons, then read the linked tiny-skia and resvg pull requests to understand the proposed 16bpc pipeline. Done would require an agreed project-scoped approach that reduces compounded rounding or explicitly confirms that this is out of scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.