Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Add support for SVG input #884

Closed
surma opened this issue Dec 9, 2020 · 9 comments
Closed

[CLI] Add support for SVG input #884

surma opened this issue Dec 9, 2020 · 9 comments
Labels
CLI CLI related issue help wanted Extra attention is needed

Comments

@surma
Copy link
Collaborator

surma commented Dec 9, 2020

No description provided.

@fernap3
Copy link

fernap3 commented Dec 9, 2020

I'd like to +1 this and just drop a use case here.

We ship a web app with the ability for clients to customize whether or not it serves SVG or PNG icons. This means we ship SVG and PNG versions of the same icons; so the use case for us is to generate the PNG versions at build time from the SVGs.

@fernap3
Copy link

fernap3 commented Dec 18, 2020

Design question: should it be a goal to be able to take an input SVG and vector-resize to any arbitrarily-sized raster format like PNG? Or would having a new "SVG" decoder return a bitmap at the intrinsic height and width of the SVG be a suitable initial goal?

Also, I see there are a couple NPM modules that will rasterize SVG. Are there any license concerns specific to this project that are worth noting? If it's not clear, I'm investigating an implementation. :)

@surma
Copy link
Collaborator Author

surma commented Dec 18, 2020

Just like the web app, resizing should happen before rasterization.

Re licensing: Anything that is Apache-2.0 or MIT should be no problem. Other licenses might work, but will be look at on a case-by-case basis.

@fernap3
Copy link

fernap3 commented Dec 29, 2020

Just brain dumping some progress here. I was able to implement an SVG decoder using Puppeteer. But I'm not sure if it's going to be acceptable to make users incur the Chromium download just to use the CLI. Maybe we could conditionally download if we detect SVG input. So this may not be the best solution, but it was quick to implement and also means SVG rasterization happens the exact same way that it does in the web app.

Other options:

  • Try to get node-canvas to work. I ran into some rollup issues since node-canvas uses native Node (.node) modules and the build was choking on that.
  • Find some other library and compile to wasm. This will probably be substantially more work.

image

@surma
Copy link
Collaborator Author

surma commented Dec 29, 2020

Yeah, using Puppeteer is not going to be an acceptable solution tbh :D

So Chromium uses Skia for painting. Skia has been ported to WebAssembly in the CanvasKit project. I wonder if that has a way to paint SVGs?

@tomByrer
Copy link

Sharp translates SVG-to-___ just fine:
https://techsparx.com/nodejs/graphics/svg-to-png.html
API is very easy also, gives me the dot-notation-fuzzies of when I used jQuerry
https://sharp.pixelplumbing.com/api-constructor

@fernap3
Copy link

fernap3 commented Mar 29, 2021

Thanks for the resource @tomByrer! I'll take a look

@kosamari kosamari added CLI CLI related issue help wanted Extra attention is needed labels Jul 1, 2021
@kosamari
Copy link
Contributor

kosamari commented Jul 1, 2021

Housekeeping Note (ignore me !) : we consider this may be complex and long-running project. We may need to break down tasks more.

@jakearchibald
Copy link
Collaborator

Unfortunately, due to a few people leaving the team, and staffing issues resulting from the current economic climate (ugh), the CLI and libsquoosh packages are no longer actively maintained. I know that sucks, but there simply isn't the time & people to work on this. If anyone from the community wants to fork it, you have my blessing. The squoosh.app web app will continue to be supported and improved.

@jakearchibald jakearchibald closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI CLI related issue help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants