Skip to content

msvg: flattens curved paths too coarsely in upscaled SVGs #7465

@peteroupc

Description

@peteroupc

ImageMagick version

7.1.1-33

Operating system

Linux

Operating system, version and so on

Fedora 40

Description

I have noticed that, when rasterizing SVGs to an upscaled raster image, msvg: appears to flatten curved paths in the SVG as though the SVG were displayed in its original resolution rather than in the upscaled resolution. This can be undesirable where the paths are flattened so coarsely that straight lines can be seen. Meanwhile, rsvg: renders curved paths more smoothly because the flattening takes place at the desired pixel size, not the original size, leading to a much more desirable behavior with such paths.

Thus, msvg: should behave like rsvg: in this respect.

Steps to Reproduce

curved1.svg:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" xmlns:xlink="http://www.w3.org/1999/xlink">
  <ellipse style='stroke:none;fill:blue' cx='4' cy='4' rx='4' ry='4'/>
</svg>

curved2.svg:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" xmlns:xlink="http://www.w3.org/1999/xlink">
  <path style='stroke:none;fill:blue' d="M1 4Q1 1 4 1Q7 1 7 4Q7 7 4 7Q1 7 1 4Z"/>
</svg>

In both SVGs, the "original" resolution is 8x8. Now run the following commands and compare the results:

magick -size 256x256 msvg:curved1.svg msvgcurved1.png
magick -size 256x256 rsvg:curved1.svg rsvgcurved1.png
magick -size 256x256 msvg:curved2.svg msvgcurved2.png
magick -size 256x256 rsvg:curved2.svg rsvgcurved2.png

Notice that rsvgcurved1.png and rsvgcurved2.png are much smoother compared to msvgcurved1.png and msvgcurved2.png.

Images

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions