Show HN: Satori – Convert HTML and CSS to SVG
github.com
github.com
Conceptually, I love this.
Mainly because for some reason it irritates me than screenshots are bitmaps.
Nearly everything in a user interface or document is vector-based, except for photographs and natural-media illustrations.
The ability to capture part of a webpage as an SVG feels like a step forwards in preserving vector content.
My real wish is that OS interfaces would be just as vector-based, where rendering to bitmap was just something the OS handled at the end. So a screenshot in macOS or Windows would similarly always be SVG.
I've been told it moved away from that as networks got faster, interfaces became more GPU-accelerated, and video encoding became hardware-accelerated, so that now it's not much different from VNC. But I don't know when or to what extent, or if RDP still uses any draw instructions at all.
I suspect that it transferred OS calls.
But even then, that would pale in comparison to SVG diffs from an SVG-native OS.
Previously new uncached requests for Open graph share-card images were generated in Chrome, sometimes taking up to 5 seconds to generate. (They were then stored in cache for 12 hrs).
Because we're now using Satori powered og images, they render almost immediately and we don't have to own the problem of having Chrome deployed within the 50mb lambda limitation. I'm pretty happy about that.
I'm curious if Satori could be used to capture in-app client-side screenshots accurately.
https://stackoverflow.com/questions/4912092/using-html5-canv...
It’s incredibly annoying that screenshotting isn’t a DOM API, while the functionality is clearly there in DevTools.
Edit: To add to the annoyance, iOS Safari is extremely stingy with canvas memory.
As if we needed more browser fingerprinting vectors.
Didn't use yoga but a from scratch implementation. A good starting point is let's build a browser engine [1]. I hope to blog about it at somepoint.
[1]: https://limpet.net/mbrubeck/2014/08/08/toy-layout-engine-1.h...
I was thinking that this was going to be a crazy amount of layout engine work, but now I look a little closer it appears the layout work is farmed out to yoga [0] (not trying to take away anything from the effort here). So this project is almost a wrapper around running yoga as a renderer and using SVG as a form of backend target?
I say "appears" because the yoga landing page doesn't do a great job of explaining what it does.
EDIT Just looking at some of the information about the font side of things and the naming is a little confusing. You set embedFont=false to use text instead of converting the text to paths. embedFont=true sounds a lot like it will embed the _font_ required to render the _text_ - but it kinda does the opposite.
Here's a blog post detailing how this works (using @vercel/og): https://vercel.com/blog/introducing-vercel-og-image-generati...
Could be a (convoluted?) way to ensure an asset looks the same across all browsers..
https://vercel.com/docs/concepts/functions/edge-functions/og...
For anyone else who’s curious it looks like the pertinent source[1] can be self-hosted. I’m on mobile so I’m gonna limit my peering into the source, but it appears to wrap Chromium to do the PNG generation. Quite a bit different from my solution (which takes SVG-producing JSX and anything producing CSS, and renders to PNG with Sharp).
I’m curious how much overhead using Chromium adds, and whether alternatives like Sharp were considered.
I recently made image export on some SVG charts that you could download as SVG and PNG and I was quite pleased I managed to do it without any library
My use cases are all very unusual, but they’d probably make portability a much simpler task because I hobbled together such a weird set of technologies.
Looks like using Satori might have been easier to use then having to do all the canvas draw calls (which isn't all that bad either though).
Edit: Nevermind. Actually looks like this wouldn't be self hostable in a github action. vercel/og doesn't run in a node runtime?
vercel/og (a wrapper around Satori) does not support node
[0]: https://github.com/vercel/satori#html-elements [1]: https://og-playground.vercel.app
[1] uses JSX
So, yeah, my comment still stands.
In the 90's there was a vector graphics editor called Satori. It was something beyond the understanding of us neighbourhood kids. Something beyond the Paint (and Paintshop Pro). Now let's get back from the nostalgia trip...
Watercolor paintings that were actually vectors? Yes, that's exactly what it offered!
There was also some architectural trickery that enabled huge pictures to be loaded into the application on machines with limited RAM.
The nearest software to this now is Synthetik Studio Artist (https://synthetik.com/).
I would like to use it with existing component library which is built using tailwind without making changes. Is that possible?
Edit: Oh I re-read your comment and you want to know if they support classnames... then my answer is not what you need :(
The html+css looked fine, but to get it to a vector image as required by the journal was a pain: print to PDF, find out the lines aren't reproduced correctly, manually find a PDF printer with the right settings, convert to eps
https://oreillymedia.github.io/Using_SVG/extras/ch07-dataURI....
Source: I just dealt with this problem a few weeks ago. I also spent all last week implementing a custom OG image in Canvas. Wish Satori had come out a week earlier!
EDIT: here's how I'm doing the embedding
<style type="text/css">
@font-face { font-family:FontName; src:url(data:font/otf;base64,T1RUTwAOAIAAAwBgQ0ZGIHKc...AAAAAAAAAAAA=) format("opentype"); }
</style>
I've passed by the Chrome SVG code a bit, and I've never seen anything to suggest there's an "SVG lite" type version in there. I imagine it's just painted to a bitmap and handed to the compositor like everything else (obviously a massive simplification).Of course they support embedding too, so you can use any font (and I think embedding is required to be conformant with Pdf-a - but I’m a little hazy on that).