Skip to content

API to convert HTML and CSS code into a lossless image using Node.js with puppeteer and a headless chromium browser.

Notifications You must be signed in to change notification settings

KaamiDev/HTML-to-Image-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML to Image

API to convert HTML and CSS code into a lossless png image using Node.js with puppeteer and a headless chromium browser.

How it works

  1. HTML and CSS data is substituted into an html page template.
  2. That template is then opened via a headless browser on the server.
  3. A screenshot it taken of the html page.
  4. The screenshot is converted into a base64 image that is sent as a response.

POST: /render

Sample Request:

{
    "html": "<h1>Hello!</h1>"
    "css": "h1 { color: blue; }"
}

Sample Response:

{
    "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAlCAYAAAAnQjt6AAAAAXNSR0..."
}

About

API to convert HTML and CSS code into a lossless image using Node.js with puppeteer and a headless chromium browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published