{"id":16278597,"url":"https://github.com/sigoden/dynimgen","last_synced_at":"2025-10-26T04:03:54.734Z","repository":{"id":62444625,"uuid":"500447183","full_name":"sigoden/dynimgen","owner":"sigoden","description":" A dynamic image generator.","archived":false,"fork":false,"pushed_at":"2022-06-20T07:43:06.000Z","size":520,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-27T21:15:52.222Z","etag":null,"topics":["dynamic-image-generator","image-generator","poster-generator","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigoden.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-06T13:35:43.000Z","updated_at":"2024-07-18T15:41:57.000Z","dependencies_parsed_at":"2022-11-01T22:16:14.226Z","dependency_job_id":null,"html_url":"https://github.com/sigoden/dynimgen","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fdynimgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fdynimgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fdynimgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fdynimgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigoden","download_url":"https://codeload.github.com/sigoden/dynimgen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228520984,"owners_count":17932663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-image-generator","image-generator","poster-generator","rust"],"created_at":"2024-10-10T18:59:06.951Z","updated_at":"2025-10-26T04:03:49.679Z","avatar_url":"https://github.com/sigoden.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dynimgen\n\n[![CI](https://github.com/sigoden/dynimgen/actions/workflows/ci.yaml/badge.svg)](https://github.com/sigoden/dynimgen/actions/workflows/ci.yaml)\n[![Crates](https://img.shields.io/crates/v/dynimgen.svg)](https://crates.io/crates/dynimgen)\n\n A dynamic image generator.\n\n![demo](https://user-images.githubusercontent.com/4012553/172307949-8e739dcd-e322-44d7-8f29-6dd9aec87d71.gif)\n\n## How to use\n\n\nstep 1: The designers export the design drawing as an svg file\n\n```svg\n\u003csvg\u003e\n  \u003crect /\u003e\n  \u003cimage src=\"img.png\" /\u003e \n  \u003cimage src=\"qr.png\" /\u003e\n  \u003ctext\u003e66666\u003c/text\u003e\n\u003c/svg\u003e\n```\n\nstep 2: The engineers edit the svg file, replace the changed parts with template variables\n\n```\n\u003csvg\u003e\n  \u003crect /\u003e\n  \u003cimg src=\"{{ img | fetch }}\"\u003e\n  \u003cimg src=\"{{ qr | to_qr }}\"\u003e\n  \u003ctext\u003e{{ code }}\u003c/text\u003e\n\u003c/svg\u003e\n```\n\nstep 3: Run `dynimgen`, make sure the svg template is in the `dynimgen` workdir\n\n```sh\n$ ls data/\nTimes New Roman.ttf   poster1.svg\n\n$ dynimgen data/\n[2022-06-05T14:51:53Z INFO  dynimgen::generator] Mount `/poster1`\n[2022-06-05T14:51:53Z INFO  dynimgen] Listen on 0.0.0.0:8080\n```\n\nstep 4: Build image url according to the following rules\n\n```\n\u003cdomain\u003e + \u003ctemplate path\u003e + ? + \u003ctemplate variables\u003e\n```\n\nFor example:\n\n- domain: http://localhost:8080\n- template path: /poster1\n- template variables: { img: \"https://picsum.photos/250\", qr: \"dynimgen\", code: 12345 }\n\nBuild url:\n\nhttp://localhost:8080/poster1?img=https://picsum.photos/250\u0026qr=dynimgen\u0026code=12345\n\nIf you request this url, dynimgen will response a png image.\n\nwhat dynimgen does:\n\n1. Extract path and variables from the request\n2. Pass variables to template engine to generate a svg\n3. Render the svg to a png then response\n\n## Install\n\n### With cargo\n\n```\ncargo install dynimgen\n```\n\n### With docker\n\n```\ndocker run -v `pwd`/data:/data  -p 8080:8080 --rm -it sigoden/dynimgen /data\n```\n\n### Binaries on macOS, Linux, Windows\n\nDownload from [Github Releases](https://github.com/sigoden/dynimgen/releases), unzip and add duf to your $PATH.\n\n## Template Engine\n\n**dynimgen** uses [Tera](https://github.com/Keats/tera) as the template engine. It has a syntax based on [Jinja2](http://jinja.pocoo.org/) and [Django](https://docs.djangoproject.com/en/3.1/topics/templates/) templates.\n\nSee the [Tera Documentation](https://tera.netlify.app/docs/#templates) for more information about [control structures](https://tera.netlify.app/docs/#control-structures), [built-ins filters](https://tera.netlify.app/docs/#built-ins), etc.\n\n\nCustom built-in filters that **dynimgen** uses:\n\n### `fetch`\n\nFetch remote resource and encode as data-url\n\nExample: `{{ img | fetch }}` `{{ img | fetch(timeout=10000) }}`  \n\n### `to_qr`\n\nConvert text to qrcode\n\nExample: `{{ qr | to_qr }}`  `{{ qr | to_qr(bg='#fff', fg='#000') }}` \n\n## License\n\nCopyright (c) 2022 dynimgen-developers.\n\ndynimgen is made available under the terms of either the MIT License or the Apache License 2.0, at your option.\n\nSee the LICENSE-APACHE and LICENSE-MIT files for license details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigoden%2Fdynimgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigoden%2Fdynimgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigoden%2Fdynimgen/lists"}