英文:
svg straight lines curved after converting to raster format (png, jpg) Sharpjs
问题
EDIT: https://github.com/lovell/sharp/issues/1421 使用密度选项
我正在使用 Sharp.js 将此 SVG 转换为 PNG:https://www.svgviewer.dev/s/fEKKksfU,但它总是看起来很奇怪。这是我进行转换的方式:
sharp(Buffer.from(`SVG HERE`)).png()
这是结果:
它看起来一点都不像原始的SVG。我不确定是否这是从SVG到光栅的限制,但我知道它不应该看起来像最终图像。提前感谢您。
使用Sharp.js将SVG转换为PNG时,线条看起来奇怪且弯曲。
英文:
EDIT: https://github.com/lovell/sharp/issues/1421 Use density option
I am converting this svg: https://www.svgviewer.dev/s/fEKKksfU, to png using Sharp.js but it always comes out looking wonky. Here is how I convert it:
sharp(Buffer.from(`SVG HERE`)).png()
and here is the result:
It does not look like the original SVG at all. I am not sure if this is a limitation of going from svg to raster but I know its not supposed to look like the final image. Thank you in advance.
SVG to PNG using Sharp.js does not come out like the original SVG. Lines are wonky and curved.
答案1
得分: 0
使用“density”选项似乎可以减轻这种效果。
英文:
I seems using the density option mitigates this effect.
sharp(Buffer.from(`SVG HERE`), {density: 500}).png()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论