jimp icon indicating copy to clipboard operation
jimp copied to clipboard

SVG support

Open SamVerschueren opened this issue 8 years ago • 21 comments

Is SVG support planned or was it left out on purpose? Just wondering as I'm looking into dropping node-gm in favour of a library that does not depend on external binaries.

SamVerschueren avatar Apr 10 '16 10:04 SamVerschueren

Jimp is bitmap based so no consideration was given to vector support. What kind of support do you have in mind?

oliver-moran avatar Apr 10 '16 12:04 oliver-moran

Loading in an SVG, resize it and write it as PNG for example.

SamVerschueren avatar Apr 10 '16 12:04 SamVerschueren

That sounds like something that would be in scope. If a pure JS library exists already then certainly we can integrate it.

oliver-moran avatar Apr 10 '16 12:04 oliver-moran

👍

radiovisual avatar Apr 18 '16 11:04 radiovisual

The only thing I can think of is rendering SVG to , but that would require an headless browser?

tomByrer avatar Apr 29 '16 03:04 tomByrer

My feeling is that getting this off the ground would be a bigger job than this project has scope for. If anything every gets build be sure I'll integrate it here. But closing for now.

oliver-moran avatar Jul 26 '16 21:07 oliver-moran

Would love to have SVG support

niftylettuce avatar Nov 25 '17 04:11 niftylettuce

My feeling is that getting this off the ground would be a bigger job than this project has scope for. If anything every gets build be sure I'll integrate it here. But closing for now.

any interest in adding SVG support for jimp at this time? i just started using jimp in a new project, and might be able to contribute a bit once I get a bit more familiar with the jimp API

thank you 😊

jamezening avatar Jan 10 '20 08:01 jamezening

It's now 2020 and SVG is one of the most common image formats on the web. It would be nice if this was reopened and reconsidered.

mririgoyen avatar Jun 26 '20 14:06 mririgoyen

Support depends entirely on finding an SVG library that decodes/encode to/from bitmap data. If this exists support should be easy. If it doesn't then you know why it currently isn't supported

hipstersmoothie avatar Jun 29 '20 15:06 hipstersmoothie

@oliver-moran @hipstersmoothie Any update on SVG support? Because, if there is SVG support we can use open type fonts too

https://www.npmjs.com/package/opentype.js

theabbie avatar Nov 03 '20 14:11 theabbie

Would the canvg library be sufficient to be able to import SVG? https://github.com/canvg/canvg

josh-hemphill avatar May 18 '21 02:05 josh-hemphill

Any update?

danilkinkin avatar Sep 22 '21 20:09 danilkinkin

I've started a PR #1049 It's very WIP, and could use some input on what the best workflow for handling pre-render transformations is (e.g. what resolution to render it at); since it's a lot different than any other plugin or type provider.

josh-hemphill avatar Sep 23 '21 16:09 josh-hemphill

Hi @josh-hemphill

Have you considered using resvg-js instead of canvg? resvg is pretty much the fastest, best supported SVG feature library available, and doesn't require the bloated node-canvas installation.

In some scenarios,resvg-js is even faster than sharp.

image

See also https://github.com/RazrFalcon/resvg#svg-support

yisibl avatar Oct 21 '21 18:10 yisibl

The reason I went with canvg despite its shortcomings is that it's a pure js implementation as far as I can tell, and since I think jimp is pure js, I figured PRs should try to keep it that way.

josh-hemphill avatar Oct 21 '21 18:10 josh-hemphill

I understand your choice, but it looks like it also introduces a non-JS dependency on node-canvas, which often fails to build on my server. node-gyp and postinstall are a terrible experience.

If this is a must-use, I'd suggest skr-canvas (@napi-rs/skia), which requires no recompilation and is much faster.

yisibl avatar Oct 22 '21 03:10 yisibl

Thanks for pointing that out, I didn't realize node-canvas shipped binaries, I was just following the example implementations that canvg had listed for Node.js. I found pureimage which seems to be a pure js implementation for canvas. It's slower, but for SVG rendering in a non-browser context that's pretty acceptable. I've updated my PR with it. There will probably be some edge cases since pureimage still has a few unsupported canvas features.

josh-hemphill avatar Oct 22 '21 04:10 josh-hemphill

Thanks for pointing that out, I didn't realize node-canvas shipped binaries, I was just following the example implementations that canvg had listed for Node.js. I found pureimage which seems to be a pure js implementation for canvas. It's slower, but for SVG rendering in a non-browser context that's pretty acceptable. I've updated my PR with it. There will probably be some edge cases since pureimage still has a few unsupported canvas features.

I don't have any particular idea about replacing it with pureimage. Performance aside, if most SVGs are tested to render correctly, then give it a try.

yisibl avatar Nov 03 '21 03:11 yisibl

Is the SVG feature integrated into JIMP now? Thanks a lot.

xeoshow avatar Feb 21 '22 11:02 xeoshow

any progress on this? Thanks a lot.

shtse8 avatar Jul 21 '22 15:07 shtse8