A simple web service that converts HTML/templates to images, with image lifecycle management support.
PORT: Service port, default is 8999IMAGE_LIFETIME_HOURS: Image lifetime in hours, default is 24 hours. Images older than this will be automatically cleaned up
Convert HTML to image
Choose either html or tmpl. Provide tmpl and tmpldata together.
strhtml: HTML textstrtmpl: Jinja2 HTML templatedicttmpldata: Jinja2 template databooljson: Whether to return JSON format (returns an id)dictoptionaloptions- timeout (float, optional): Screenshot timeout.
- type (Literal["jpeg", "png"], optional): Screenshot image type.
- quality (int, optional): Screenshot quality, only applicable to JPEG format.
- omit_background (bool, optional): Whether to hide the default white background, allowing transparent screenshots (PNG only).
- full_page (bool, optional): Whether to capture the entire page instead of just the viewport, default is True.
- clip (FloatRect, optional): Area to clip after screenshot, xy is the starting point.
- animations: (Literal["allow", "disabled"], optional): Whether to allow CSS animations.
- caret: (Literal["hide", "initial"], optional): When set to
hide, the text caret will be hidden during screenshot, default ishide. - scale: (Literal["css", "device"], optional): Page scaling settings. When set to
css, device resolution maps 1:1 with CSS pixels, making screenshots smaller on high-DPI screens. When set todevice, scales according to device screen scaling or the device_scale_factor parameter in the current Playwright Page/Context. - viewport_width (int, optional): Custom viewport width to control screenshot width.
- device_scale_factor_level (Literal["normal", "high", "ultra"], optional): Device pixel ratio level, default is "normal". Different levels use independent browser context pools for better performance and resource isolation.
normal: Device pixel ratio 1.0 (default)high: Device pixel ratio 1.3ultra: Device pixel ratio 1.8
Returns the corresponding image by id.