svg 直线在转换为光栅格式(png、jpg)后变为曲线 Sharpjs

huangapple go评论69阅读模式
英文:

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:

result image

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()

huangapple
  • 本文由 发表于 2023年2月10日 06:23:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75405074.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定