Bratification
Generate brat-style images from text using the bundled Python scripts.
Quick start
- For a plain render, run
scripts/render_brat.py. - For command-style parsing like
!brat hello world, runscripts/handle_brat_command.py. - Prefer white background, Arial Narrow bold (with cross-platform font fallback), centered composition, word wrapping without cutting words, and automatic font shrink to fit.
handle_brat_command.pynow sanitizes slug/output naming and always writes into its managedscripts/outdirectory tree.
Workflow
- Decide whether the request is direct text rendering or
!bratcommand parsing. - Use
scripts/handle_brat_command.pyfor command-style input. - Use
scripts/render_brat.pyfor direct text-to-image rendering. - For WhatsApp-safe sticker-like delivery, prefer
--size 512 --sticker-size 512and send the generated PNG with no caption. - Treat WEBP as an optional artifact unless the channel has verified native sticker upload support.
Commands
Render text directly
python scripts/render_brat.py "hello world" --png out/hello-world.png --webp out/hello-world.webp
Parse a !brat command
python scripts/handle_brat_command.py "!brat hello world"
Sticker-like WhatsApp-safe output
python scripts/handle_brat_command.py --size 512 --sticker-size 512 "!brat hello world"
Output handling
- Use PNG as the primary reliable delivery format.
- Use WEBP as a secondary artifact for future native-sticker-capable channels.
- If the input is only
!bratwith no text, ask briefly for the text. - If generation fails, apologize briefly and say the brat render failed.
Scripts
scripts/render_brat.py: deterministic renderer for PNG/WEBP outputscripts/handle_brat_command.py: parser for!brat-style input that emits JSON with generated paths