TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/andresilva-cc/grafex/llms.txt
Use this file to discover all available pages before exploring further.
grafex export command renders a composition file to an image on disk. It launches a headless browser, loads your JSX/TSX composition, and captures the result as a PNG or JPEG. For compositions that define multiple variants, a single invocation renders every variant and writes each output to a named file — no shell loop required.
Usage
Flags
Path to the
.tsx composition file to render. Short form: -f.Output file path or directory. Short form:
-o.- For a single-variant composition, this is the path to the output file (e.g.
./card.png). Defaults to./output.png. - For a multi-variant composition, this must be a directory path (e.g.
./images/). Defaults to./. Each variant is written as<variant-name>.<format>inside that directory. Passing a single file path with multiple variants is an error.
Props to pass to the composition’s default export, serialised as a JSON string. The string must be valid JSON.
Override the composition width in pixels, ignoring the
width set in config. Must be an integer.Override the composition height in pixels, ignoring the
height set in config. Must be an integer.Output image format. Accepted values:
png, jpeg. The alias jpg is also accepted and treated identically to jpeg.JPEG compression quality, from
1 (lowest) to 100 (highest). Has no effect when --format is png — a warning is printed if you combine the two.Device pixel ratio. Set to
2 to produce a retina / high-DPI image: a 1200 × 630 composition with --scale 2 writes a 2400 × 1260 pixel file while preserving the logical layout at 1200 × 630.Browser engine to use for rendering. Accepted values:
webkit, chromium. Chromium must be installed separately (npx playwright install chromium) before it can be used.Render only the named variant defined in
config.variants. When omitted, all variants are rendered. Has no effect on compositions that do not define variants.Print the help text and exit. Short form:
-h.Examples
Multi-variant behaviour
When a composition exports aconfig.variants object, grafex export renders every variant in a single pass unless --variant is specified.
The output directory is created automatically with
mkdirSync({ recursive: true }) if it does not exist — you do not need to mkdir it first.Format and quality notes
| Format | --quality effect | Recommended use |
|---|---|---|
png | None (warning printed if set) | Lossless output, screenshots, images with transparency |
jpeg | Controls compression, 1–100, default 90 | Photos, large backgrounds, smaller file sizes |
Global flags
The following flags are available on the top-levelgrafex command, before any subcommand: