@codeimage/cli
v1.0.1
Published
Generate beautiful code images from the command line
Maintainers
Readme
@codeimage/cli
Generate beautiful code images from the command line! 🎨
Installation
# Install globally
npm install -g @codeimage/cli
# Or use with npx
npx @codeimage/cli generate file.jsQuick Start
# Generate image from file
codeimage generate file.js
# Generate image from code snippet
codeimage generate "console.log('Hello World!')" --language javascript
# Generate with custom theme and frame
codeimage generate file.js --theme dark --frame clerk
# Interactive mode
codeimage interactiveCommands
generate <input>
Generate a code image from file, code snippet, or URL.
Options:
-t, --theme <theme>- Theme (dark, light, auto, github, monokai, dracula)-f, --frame <frame>- Frame style (tailwind, clerk, mintlify, minimal, macos)-l, --language <language>- Programming language (auto-detect if not specified)-o, --output <file>- Output file path-s, --size <size>- Image size multiplier (1x, 2x, 3x)-p, --padding <padding>- Padding around code (small, medium, large)--width <width>- Custom width in pixels--height <height>- Custom height in pixels--background- Show background pattern (default: true)--no-background- Hide background pattern--share- Generate a shareable link
Examples:
# Basic usage
codeimage generate file.js
# With custom theme and frame
codeimage generate file.js --theme dracula --frame clerk
# Generate from code snippet
codeimage generate "function hello() { console.log('world'); }" --language javascript
# High resolution with custom padding
codeimage generate file.js --size 3x --padding large
# Generate shareable link
codeimage generate file.js --shareinteractive
Launch interactive mode for guided image generation.
codeimage interactivethemes
List all available themes.
codeimage themesframes
List all available frame styles.
codeimage framesThemes
- dark - Dark theme with syntax highlighting
- light - Light theme with syntax highlighting
- github - GitHub-style theme
- monokai - Monokai color scheme
- dracula - Dracula color scheme
- auto - Auto-detect based on system preference
Frame Styles
- tailwind - Clean Tailwind-style frame
- clerk - Dark Clerk-style frame
- mintlify - Mintlify documentation style
- minimal - Minimal borderless frame
- macos - macOS window style
Supported Languages
Auto-detection supports:
- JavaScript/TypeScript
- Python
- Java
- C#/C++
- Go
- Rust
- PHP
- Ruby
- Swift
- Kotlin
- HTML/CSS
- SQL
- JSON/YAML
- Markdown
- And more!
Examples
Generate from File
codeimage generate src/components/Button.tsx --theme dark --frame tailwindGenerate from Code Snippet
codeimage generate "const hello = () => console.log('world');" --language javascript --theme monokaiHigh Resolution Export
codeimage generate file.js --size 3x --output high-res-code.pngGenerate Shareable Link
codeimage generate file.js --share
# Output: https://codeimage.com/share?code=...Configuration
You can create a .codeimagerc file in your project root:
{
"theme": "dark",
"frame": "tailwind",
"size": "2x",
"padding": "medium",
"background": true
}Integration
CI/CD Pipeline
# GitHub Actions example
- name: Generate code images
run: |
npm install -g @codeimage/cli
codeimage generate src/ --output docs/images/Package.json Scripts
{
"scripts": {
"generate-images": "codeimage generate src/ --output docs/",
"screenshot-code": "codeimage interactive"
}
}API
The package also exports a programmatic API:
const { generateImage } = require('@codeimage/cli');
const result = await generateImage('console.log("hello");', {
theme: 'dark',
frame: 'tailwind',
language: 'javascript',
output: 'output.png'
});