SVG to PNG
image_svg_to_pngConverts SVG files or code into crisp PNG images at a set scale or exact pixel size, with transparent or solid backgrounds and unit-aware dimensions.
Instructions
Rasterise an SVG to a crisp PNG: scale (1×, 2×, 3×, 4×… default 2×), a target width or height (aspect kept), or an exact size (stretched). Units (px, pt, mm, cm, in) and viewBox-only SVGs are understood; transparent background or a solid colour. Scripts, event handlers and external references are removed first. Name @2x.png. Web version: https://s3eidat.github.io/svg-to-png/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| svg | No | The SVG: a local path or base64 / data URI. | |
| mode | No | How to size the PNG. Default scale. | scale |
| scale | No | Scale factor for mode "scale". Default 2. | |
| width | No | Width in px for modes width / exact. | |
| height | No | Height in px for modes height / exact. | |
| output | No | Where to write the result: a file path, or a folder ending in "/". Default: the server output folder (a temp folder unless --out-dir is set). | |
| svgText | No | Or: the SVG code itself. | |
| background | No | Background colour when transparent is false. Default #ffffff. | #ffffff |
| transparent | No | Keep the background transparent. Default true. | |
| returnBase64 | No | Also return the output as base64 in the result (only for small files). Default false. |