@codetoimage/cli
v0.1.1
Published
Official CLI for codetoimage.app — render HTML/CSS to PNG/JPG/WebP from your terminal.
Downloads
209
Maintainers
Readme
@codetoimage/cli
Official CLI for codetoimage.app — render HTML/CSS to PNG/JPG/WebP from your terminal.
Install
npm install -g @codetoimage/cliOr run without installing:
npx @codetoimage/cli render index.html -o out.pngQuickstart
# 1. Authenticate (paste an API key from https://codetoimage.app/dashboard/keys)
cti login
# 2. Render an HTML file
cti render hello.html -o hello.png
# 3. Or render inline HTML
cti render --html '<h1 style="font-family:sans-serif">Hi</h1>' -o hi.pngExamples
# JPEG at 1200×630, custom background
cti render og.html -f jpeg --quality 90 -w 1200 -h 630 --background "#0a0a0a"
# Separate CSS file
cti render card.html --css card.css -o card.png
# Transparent PNG (paid plans only)
cti render badge.html --transparent -o badge.png
# Get a temporary URL instead of bytes (output:"url" mode — needs R2 backing)
cti render og.html --url
# → https://render.codetoimage.app/r/abc123.pngAuthentication
Three ways to supply your API key, in priority order:
--api-key <key>flag (per-call)CODETOIMAGE_API_KEYenvironment variable~/.config/codetoimage/config.json(created bycti login, chmod 600)
Configuration
| Variable | Default | Purpose |
|---|---|---|
| CODETOIMAGE_API_KEY | – | API key (overrides stored config) |
| CODETOIMAGE_API_URL | https://api.codetoimage.app | API base URL (override for dev/proxy) |
Exit codes
0— success1— error (auth, validation, network, plan limit, …); details on stderr
Commands
cti login Save an API key locally
cti render [input] Render HTML to image
cti --version Print CLI version
cti --help Show helpRun cti render --help for the full flag list.
License
MIT
