jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
13.97k stars 761 forks source link

SVG support #118

Open SamVerschueren opened 8 years ago

SamVerschueren commented 8 years ago

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.

oliver-moran commented 8 years ago

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

SamVerschueren commented 8 years ago

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

oliver-moran commented 8 years ago

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

radiovisual commented 8 years ago

👍

tomByrer commented 8 years ago

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

oliver-moran commented 8 years ago

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.

niftylettuce commented 6 years ago

Would love to have SVG support

jamezening commented 4 years ago

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 😊

mririgoyen commented 4 years ago

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.

hipstersmoothie commented 4 years ago

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

theabbie commented 3 years ago

@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

josh-hemphill commented 3 years ago

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

danilkinkin commented 3 years ago

Any update?

josh-hemphill commented 3 years ago

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.

yisibl commented 2 years ago

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

josh-hemphill commented 2 years ago

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.

yisibl commented 2 years ago

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.

josh-hemphill commented 2 years ago

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.

yisibl commented 2 years ago

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.

xeoshow commented 2 years ago

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

shtse8 commented 2 years ago

any progress on this? Thanks a lot.