8000 GitHub - jameswragg/html-to-png
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jameswragg/html-to-png

Repository files navigation

html-to-png

Example repo showing how og:image images can be generated using:

  • hapi - web server & API
  • hapi-swagger - Swagger interface for the API
  • nunjucks - template the HTML
  • juice - inline all CSS properties to style attributes & resolve CSS variables
  • satori-html - convert an HTML string to a React compatible VDOM object for satori
  • satori - convert HTML and CSS to SVG
  • sharp - used to process & convert image formats

Notes

The client id, logo & font URLs are supplied as querystrings.

There are the following methods available on the hapi server, both have in-memory caching:

  • fetchText
  • fetchAsBase64

Benchmark

Autocannon benchmark (npm run benchmark) results:

┌─────────┬────────┬────────┬────────┬────────┬───────────┬──────────┬────────┐
│ Stat    │ 2.5%   │ 50%    │ 97.5%  │ 99%    │ Avg       │ Stdev    │ Max    │
├─────────┼────────┼────────┼────────┼────────┼───────────┼──────────┼────────┤
│ Latency │ 198 ms │ 260 ms │ 336 ms │ 378 ms │ 261.29 ms │ 35.52 ms │ 400 ms │
└─────────┴────────┴────────┴────────┴────────┴───────────┴──────────┴────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg     │ Stdev   │ Min     │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Req/Sec   │ 33      │ 33      │ 38      │ 41      │ 37.6    │ 2.01    │ 33      │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Bytes/Sec │ 1.26 MB │ 1.26 MB │ 1.45 MB │ 1.56 MB │ 1.43 MB │ 76.6 kB │ 1.26 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0