Skip to content

kylemcdonald/fast-html-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast HTML Renderer

A high-performance HTML to PNG renderer using Playwright and headless Chrome. This tool is optimized for batch rendering thousands of frames at high speed (30+ FPS) with minimal overhead.

Features

  • Efficient HTML to PNG rendering
  • Support for complex CSS, fonts, and transparency
  • Batch processing capabilities
  • Asynchronous operation for optimal performance
  • Minimal overhead for high-throughput rendering

Installation

  1. Create and activate the conda environment:
conda env create -f environment.yml
conda activate fast-html-renderer
  1. Install Playwright and its dependencies:
playwright install chromium

Usage

Basic example:

import asyncio
from fast_html_renderer import render_html_to_png

html = "<html><body style='font-family:sans-serif;color:white;background:transparent;'><h1>Hello, World!</h1></body></html>"
asyncio.run(render_html_to_png(html, "output.png"))

Batch rendering example:

import asyncio
from fast_html_renderer import batch_render

html_frames = [
    f"<div style='font-size:50px;color:white;'>Frame {i}</div>"
    for i in range(1000)
]

asyncio.run(batch_render(html_frames))

Performance

  • Capable of rendering at 30+ FPS
  • Optimized for batch processing thousands of frames
  • Minimal overhead through browser instance reuse
  • Efficient memory usage through proper resource management

Requirements

  • Python 3.8+
  • Playwright
  • Chromium (installed automatically by Playwright)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages