viewbox values get rounded to nearest int
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 348
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
Not much to explain here, the issue is quite simple. I hope the fix will be simple too 🤞🏻 I've attached some renders of a test image. I tested in resvg 0.41 and 0.43
```svg
```
| Impl | Image | viewbox size | command |
|--------|--------|--------|--------|
| Your Browser |  | - | - |
| rsvg |  | 1.5x1.5 | `rsvg-convert test.svg -w 100 -o test_rsvg.png` |
| inkscape |  | 1.5x1.5 | `inkscape "/home/riedler/Downloads/test.svg" --export-filename="test_inkscape.png" -w 100` |
| resvg |  | 2x2 | `resvg test.svg -w 100 test_resvg.png ` |
note that this is less of an issue when rounded up, but quite a big issue when rounded down, since some SVGs are perfectly cut to their contents. I feel that a suitable hotfix would be always rounding up, and cutting the resulting bitmap image to the proper size afterwards.
I didn't test whether aspect ratio is preserved e.g. when `viewBox="0 0 1.5 2"`, but I assume that's also an issue.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided SVG and the resvg CLI command, comparing its 2x2 output with rsvg and Inkscape. Trace the viewBox sizing and raster-output path responsible for converting the 1.5×1.5 viewBox, then verify that fractional dimensions and the mentioned non-square aspect ratio render without unwanted rounding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100