Hacker News new | ask | show | jobs
by vbezhenar 3223 days ago
Headless chrome is awesome. I'm using it to generate multiple PNG from SVG.
2 comments

I agree with you but as a 'old' developer, I find it pretty sad that you have to fire up a headless browser + its gigaton of code, to convert a SVG to PNG. But I agree with you, headless chrome can be very useful.
We currently use Apache Batik (JVM/Scala) to generate PNG for server generated SVGs of charts. SVG is wonderful for generating charts, easy even without any framework.
I take your point in general, but I'm not sure this specific task - converting of SVGs - has ever been one that has easily been solved by some tiny amount of code: probably the way I would have done this in the past (say, ten years ago) would have been using Apache Batik's rasteriser, which is far from a lightweight solution itself.
It's not tiny, but in case anybody else is trying to do the same thing, I'd reach for librsvg (https://wiki.gnome.org/Projects/LibRsvg).
You could also do that with inkscape on the commandline, not sure if it's faster, though...
Indeed, I see lately many cool projects emerging. Is a pity that not all projects are using the same GitHub tag #headless-chromium [1]

This other project[2] was recently on HN but you can't find it easily on github search.

[1] https://github.com/search?q=topic%3Aheadless-chromium&type=R...

[2] https://github.com/DevExpress/testcafe