open graph real easy
ogre#
open graph real easy: a simple CLI tool for generating open graph images.
installation#
go install tangled.org/jakelazaroff.com/ogre/cmd/ogre@latest
usage#
ogre [-o output.png] <config.toml> [Key=Value ...]
key=value pairs are substituted into the config as go template variables.
ogre -o og.png template.toml Title="An Interactive Intro to CRDTs" Date="october 3, 2023"
config#
configure ogre via a TOML template:
layers are drawn in order — later layers appear on top.
width = 1200 # default: 1200
height = 630 # default: 630
background = "#6B5BFF"
[[layers]]
type = "text"
position = "bottom-left"
font = "./LeagueGothic-Regular.ttf"
size = 78
color = "#ffffff"
padding = 40
text = "{{.Title}}"
anchor = "baseline" # "baseline" measures padding from the baseline rather than
# the font's bounding box — useful when text has no descenders
spacing = -2 # letter-spacing in pixels (negative = tighter)
wrap = 800 # max width in pixels before text wraps
[[layers]]
type = "image"
src = "./photo.jpg"
position = "bottom-right" # omit to fill the canvas
padding = 40
width = 200 # omit to use native size
height = 200
opacity = 0.5 # 0.0–1.0, default 1.0
positions#
top-left top-center top-right
middle-left center middle-right
bottom-left bottom-center bottom-right
multiline text#
use \n in the text field to insert line breaks.
development#
run tests:
cd internal/render && go test
update snapshots after intentional rendering changes:
cd internal/render && go test -update