A dynamic image generator.

Overview

dynimgen

CI Crates

A dynamic image generator.

demo

How to use

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

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

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

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

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

$ ls data/
Times New Roman.ttf   poster1.svg

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

step 4: Build image url according to the following rules

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

For example:

Build url:

http://localhost:8080/poster1?img=https://picsum.photos/250&qr=dynimgen&code=12345

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

what dynimgen does:

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

Install

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

Fetch remote resource and encode as data-url

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

to_qr

Convert text to qrcode

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

License

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.

You might also like...
Universal changelog generator using conventional commit+ with monorepo support. Written in Rust.
Universal changelog generator using conventional commit+ with monorepo support. Written in Rust.

chlog Universal changelog generator using conventional commit+ with monorepo support. chlog can generate the changelog from the conventional commits w

A simple, fast, easy README generator
A simple, fast, easy README generator

Welcome to Readme Generator A simple, fast, easy README generator. Never worry about READMEs again! What it does: Run the command in your project's di

A simple quote-based code generator for Rust

flexgen A flexible, yet simple quote-based code generator for creating beautiful Rust code Why? Rust has two types of macros, and they are both very p

Flexible snowflake generator, reference snoyflake and leaf.

Flexible snowflake generator, reference snoyflake and leaf.

Quad-rand implements pseudo-random generator

quad-rand quad-rand implements pseudo-random generator based on rust atomics. Compatible with wasm and any oth

⚙️ A cute .gitignore generator with support for custom templates
⚙️ A cute .gitignore generator with support for custom templates

Gign A Gitignore Generator Table of Contents Examples Install Custom templates Help Examples # This is how you going to use it probably most of the ti

Nexmark event generator in Rust.

Nexmark-rs The Nexmark benchmark data generator in Rust. Installation cargo install nexmark --features bin Usage Generate nexmark events. Print one pe

A code generator to reduce repetitive tasks and build high-quality Rust libraries. 🦀

LibMake A code generator to reduce repetitive tasks and build high-quality Rust libraries Welcome to libmake 👋 Website • Documentation • Report Bug •

waveplot is a VCD waveform generator for the terminal.

waveplot waveplot is a VCD waveform generator for the terminal. Installation (dev) Install the Rust compiler 'rustc' using rustup. curl --proto '=http

Owner
null
A dynamic binary tracing tool

Backlight Backlight is a dynamic binary tracing tool. Install $ git clone [email protected]:JoshMcguigan/backlight.git $ cd backlight $ cargo install-b

Josh Mcguigan 42 Dec 3, 2022
An example app in Rust for CircleCI's Dynamic Config demo

circleci-dynamic-config-example An example app in Rust for CircleCI's dynamic config demo. Dynamic config allows you to dynamically generate CircleCI'

yujiosaka 2 Oct 6, 2022
Prints the absolute path of all regular files in an unmounted btrfs filesystem image.

btrfs-walk-tut Prints the absolute path of all regular files in an unmounted btrfs filesystem image. Learning about btrfs: Btrfs Basics Series This re

Nishal Kulkarni 2 Feb 3, 2022
Ever wanted to torture your CPU by generating every image possible?

dumpsterfire Ever wanted to torture your CPU by generating every image possible? Well, now you can! This thing is worse than mining Bitcoin, since the

null 2 Jun 14, 2022
image url web-scrapper written in rust

imgs - CLI Webscrapper image url web-scrapper written in rust This is a cli application completely written in rust, it aim is to scrap image-url from

Michael Olayemi 1 Apr 2, 2022
Image optimization using Rust and Vips 🦀

Huffman Image optimization using Rust and Libvips. Requirements You must have the following packages installed before getting started Rust Vips pkg-co

ChronicleHQ 4 Nov 3, 2022
Small library for text to image steganography.

hips-lib Performs text to image steganography by hinding and retrieving secret text within images or pixel arrays. This is achieved by encoding the se

hewhocopypastes 4 Feb 21, 2023
A tool that transforms an IMVU badge canvas into a single cohesive image.

IMVU Badge Canvas Image Generator This tool fetches an IMVU user's badge canvas and creates a single unified image representation of it. Instead of ha

Helba 3 Sep 20, 2023
🦀 Rust-based implementation of a Snowflake Generator which communicates using gRPC

Clawflake Clawflake is a Rust application which implements Twitter Snowflakes and communicates using gRPC. Snowflake ID numbers are 63 bits integers s

n1c00o 5 Oct 31, 2022
A simple code boilerplate generator written in Rust.

?? Cgen What is Cgen? A modern, cross-platform, multi-language boilerplate generator aimed to make your code generation less hectic! If you wish to su

Rithul Kamesh 1 Dec 25, 2021