API to convert HTML and CSS code into a lossless png image using Node.js with puppeteer and a headless chromium browser.
- HTML and CSS data is substituted into an html page template.
- That template is then opened via a headless browser on the server.
- A screenshot it taken of the html page.
- The screenshot is converted into a base64 image that is sent as a response.
Sample Request:
{
"html": "<h1>Hello!</h1>"
"css": "h1 { color: blue; }"
}
Sample Response:
{
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAlCAYAAAAnQjt6AAAAAXNSR0..."
}