#dynamic #image #server #generator #cli

app dynimgen

A self-hosted dynamic image generator

2 unstable releases

0.2.0 Jun 7, 2022
0.1.0 Jun 6, 2022

#745 in HTTP server


369 lines


CI Crates

A self-hosted dynamic image generator.

How to use

step 1: The designers export the design drawing as an svg file

  <rect />
  <image src="img.png" /> 
  <image src="qr.png" />

step 2: The engineers edit the svg file, replace the changed parts with template variables

  <rect />
  <img src="{{ img | fetch }}">
  <img src="{{ qr | to_qr }}">
  <text>{{ code }}</text>

step 3: Run dynimgen, make sure the svg template is in the dynimgen workdir

$ ls data

$ dynimgen fixtures/
[2022-06-05T14:51:53Z INFO  dynimgen::generator] Mount `/poster1`
[2022-06-05T14:51:53Z INFO  dynimgen] Listen on

step 4: Build image url according to the following rules

<domain> + <template path> + ? + <template variables>

For example:

Build url:


If you request this url, dynimgen will response a png image.

what dynimgen does:

  1. Extract variables from the url query of request
  2. Pass variables to template engine to generate a svg
  3. Render the svg to a png then response


Server-side rendering advantages

  • No browser compatibility, platform compatibility and other issues
  • Code reusability is high, and the poster generation service of h5, applet, and app can be used.
  • Can be updated in a timely and convenient manner

SVG Template Advantages

  • Export SVG directly from design software such as PS/AI
  • No need to reproduce the implementation with html/canvas/dsl
  • Lossless restoration of the design draft without losing any details
  • Free use of font styles

RUST Advantage

  • High performance, high concurrency
  • Single executable program, cross-platform, easy to deploy


With cargo

cargo install dynimgen

With docker

docker run -v `pwd`/data:/data  -p 8080:8080 --rm -it sigoden/dynimgen /data

Binaries on macOS, Linux, Windows

Download from Github Releases, unzip and add duf to your $PATH.

Template Engine

dynimgen uses Tera as the template engine. It has a syntax based on Jinja2 and Django templates.

See the Tera Documentation for more information about control structures, built-ins filters, etc.

Custom built-in filters that dynimgen uses:


Fetch remote resource and encode as data-url

Example: {{ img | fetch }} {{ img | fetch(timeout=10000) }}


Convert text to qrcode

Example: {{ qr | to_qr }} {{ qr | to_qr(bg='#fff', fg='#000') }}


Copyright (c) 2022 dynimgen-developers.

dynimgen is made available under the terms of either the MIT License or the Apache License 2.0, at your option.

See the LICENSE-APACHE and LICENSE-MIT files for license details.


~407K SLoC