@xayz/brat-generator
v1.0.0
Published
Generate brat-style cover images and word-by-word reveal videos from text. Use it as a Node.js library, a CLI, or a bundled HTTP server callable from any programming language.
Maintainers
Readme
brat-generator
Generate brat-style cover images and word-by-word reveal videos from text. Use it as a Node.js library, a CLI, or a bundled HTTP server callable from any programming language.
npm install brat-generatorconst { generateBrat, generateBratVideo } = require('brat-generator')
const fs = require('fs')
const image = await generateBrat({ text: 'Hello World', theme: 'green' })
fs.writeFileSync('brat.png', image)Use it from any language
Command line (no code required):
npx brat-generator image "Hello World" --theme green --out brat.png
npx brat-generator video "Hello World" --format mp4 --out brat.mp4HTTP server (call it from Python, PHP, Java, Go, curl, anything):
npx brat-generator-server
# GET http://localhost:4000/brat?text=Hello%20WorldAPI
generateBrat(options): Promise<Buffer>
| Option | Type | Default |
|---|---|---|
| text | string | (required) |
| theme | 'black' \| 'white' \| 'green' | 'white' |
| blur | 0 \| 1 \| 2 \| 3 | 0 |
generateBratVideo(options): Promise<{ buffer, format, mimeType }>
| Option | Type | Default |
|---|---|---|
| text | string | (required) |
| theme | 'black' \| 'white' \| 'green' | 'white' |
| blur | 0 \| 1 \| 2 \| 3 | 0 |
| format | 'mp4' \| 'gif' | 'mp4' |
| frameDuration | number (seconds) | 0.35 |
| holdDuration | number (seconds) | 1.2 |
| maxWordPerLayer | number | 1 |
| maxWordBeforeReset | number | number[] | 0 |
More examples for Python, PHP, and shell/curl are in examples/. Full docs: see TUTORIAL-HOW-TO-USE.md in the project repository.
License
MIT
