This docker container enables you to create images from links. This is pretty useful for using in blogs or automations (like n8n).
- Customizable presets (for sizes or templates)
- Highly customziable via HTML/CSS
- Complete support fΓΌpr custom fonts
- Built-in TailwindCSS support
- Runs within a Docker container
- Secured by configurable
API_KEY
- Generate images from URLs with OpenGraph fetching
Note
Using the API_KEY
is mandatory to prevent unauthorized access
To use this piece of software you need a Docker host. Just run the following command and you're good to go:
docker run
-d --name='text2image'
-e 'API_KEY'='[YOUR API-KEY]'
-p '3000:3000/tcp'
-v '/mnt/user/appdata/text2image/config':'/text2image/config':'rw'
-v '/mnt/user/appdata/text2image/logs':'/text2image/logs':'rw' 'disane/text2image'
'disane/text2image'
Important
Please don't forget to mount the config
andlog
folder. You can do that with docker volumnes against /text2image/config
or /text2image/log/
Note
If you mount the folders the default content is only copied once! Therefore you won't get new templates. If you want to get the latest stuff, you have do remove all mounted folders and restart the container. Make a backup of your files. The System will copy the default stuff if they are missing. After that you can copy/replace your changes. Currently there is no migration or merging your content with new one.
You can create new images by browsing the following url (only GET
is supported):
curl -XGET 'https://[YOUR URL]:3000/image/[:preset]/[image]/?url=https://images.unsplash.com/photo-1682686581660-3693f0c588d2&apiKey=[YOUR APIKEY]'
Param | Mandatory | Default | Description |
---|---|---|---|
preset | β | null | Preset to use. Defined in `./config/presets.json` |
openGraphUrl | β | false | Activates fetching opengraph data from given url |
image | β | null | Filename with extension |
apiKey | β | null | Your defined API-Key |
Note
All other parameters in query string will be passed into the data
to use in the template. See customizing for more.
Method POST
supports/needs all GET
parameters but you can enrich the data for the template by giving the POST
an application/json
payload with this structure:
{
"data": {
"test": "yes"
}
}
Important
You need an object data
in your payload!
You can add presets
for different purposes like social media images or something else. All presets are defined in ./config/presets.json
:
{
"blog": {
"sizes": {
"width": 1920,
"height": 1080
},
"template": "blog.hbs"
},
"instagram": {
"sizes": {
"width": 1080,
"height": 1080
},
"template": "instagram.hbs"
}
}
Note
Every preset has only one template. This templates uses simple HTML/CSS with native TailwindCSS support.
With handlebars it's possible to use pre-defined data within preset templates.
These variables/placeholders are available in the template:
export interface TemplateData {
url?: string; // filled when query param `url`` is used
queryParams?: { [key: string]: unknown }; // contains all query params
data?: { [key: string]: unknown }; // contains all data in payload.data
openGraph?: { [key: string]: string }; // contains all opengraph data (when `openGraphUrl` is used)
}
available.
We're exposing a head.hbs
template to enable custom HTML stuff, like custom fonts:
GET https://[YOUR URL]/image/instagram/test.jpg/?openGraphURl=https://blog.disane.dev/pseudo-selector-nth-child-ganz-einfach-erklart/
GET https://[YOUR URL]/image/blog/test.jpg?url=https://images.unsplash.com/photo-1682687982468-4584ff11f88a&text=Wonderful%20image
Note
You can even mix params from query string with data form an webpage via OpenGraph