3 ms·
Semi-related, there's this browser extension that somehow manages to mangle HTML into SVG with pretty good accuracy. https://addons.mozilla.org/en-US/firefox/ad
by bscphil 4y ago
Semi-related, there's this browser extension that somehow manages to mangle HTML into SVG with pretty good accuracy. https://addons.mozilla.org/en-US/firefox/addon/svg-screenshots/ https://addons.mozilla.org/en-US/firefox/addon/svg-screensho...
I do stuff like this (vector representations of the DOM) for taking screenshots. Why?
1. High resolution screenshots are great when you're sharing from a low resolution device, or when you need to scale them up. I've seen enough crappy screenshots of Twitter in YouTube videos to last me the rest of my life.
2. If your device does sub-pixel anti-aliasing, then your screenshots all have noticeable color fringing around their text. The text rendering is done well before the data hits the buffer that the screenshot is capturing. A fun party trick is to identify someone's OS based purely on a screenshot of some text on a webpage.
3. On Linux (and maybe elsewhere, IDK), color correction (e.g. gamut mapping) is done (in X11) before the pixels get to the buffer that you capture. So with most screenshot tools, you end up capturing a bunch of distorted colors which you then have to map back to sRGB if you want them to look right in color calibrated software.
You can frequently get away with printing a PDF and then rendering that out to a large PNG. In some cases, though, figuring out how to set the page size to match what you seen on the screen can be near-impossible, and more importantly in Firefox there's no way to disable print media CSS when printing a PDF. (You can do this in Chromium.) If you need to edit the image afterwards or want to put it on a website or something, this is far easier to do with the SVG format than with PDF.
- cjr 4y ago> figuring out how to set the page size to match what you see on the screen can be near-impossible I run a little API that converts URLs and HTML into PNG/PDF/SVG.. MP4 too, and the quoted part resonates :) I recently started delving into the chromium src code in order to try and figure out the reason why max-width media queries don't seem to trigger at the expected viewport/page width, when printing to PDF, but it is quite the rabbit hole. When I saw html2svg the first thing I wondered was whether it would have the same issue as printing to PDF.