Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Node / Canvas · guide

Primary backgrounds (pick exactly one)

Current Apexify.js 6.0.0 documentation for Primary backgrounds (pick exactly one).

apexify.jsRuntime: nodeCURRENTSince 6.0.0

The rule

Among colorBg, gradientBg, customBg, videoBg, and transparentBase: true, activate only one primary background per call.

If multiple primary backgrounds are configured, createCanvas rejects the configuration before painting.


Option A — Solid color (colorBg)

SOURCEtypescript
typescript
Studio
await painter.createCanvas({  width: 800,  height: 450,  colorBg: '#0f172a',});

Special: colorBg: 'transparent' skips painting opaque color on that branch (often paired with transparent base or layers).


Option B — Gradient (gradientBg)

Uses GradientConfig: linear, radial, or conic with colors stops.

SOURCEtypescript
typescript
Studio
await painter.createCanvas({  width: 900,  height: 500,  gradientBg: {    type: 'linear',    startX: 0,    startY: 0,    endX: 900,    endY: 500,    colors: [      { stop: 0, color: '#312e81' },      { stop: 1, color: '#1e1b4b' },    ],  },});

Option C — Image (customBg)

FieldPurpose
sourceFile path or http(s) URL
inherittrue → set width/height from image
fitfill | contain | cover
alignPosition when letterboxing
opacityLayer alpha
filtersOptional ImageFilter[]
SOURCEtypescript
typescript
Studio
await painter.createCanvas({  width: 1200,  height: 630,  customBg: {    source: './assets/hero.jpg',    fit: 'cover',    align: 'center',  },});

Option D — Video frame (videoBg)

Requires FFmpeg. Apexify extracts one still frame once, then renders that still through the same image-background placement/filter pipeline as customBg.

FieldPurpose
sourcePath, URL, or Buffer
frame1-based frame number; mutually exclusive with time
timeTimestamp in seconds; mutually exclusive with frame
format, qualityjpg | png, FFmpeg image quality 1–31
inherittrue → use extracted-frame width/height for the canvas
fitfill | contain | cover
alignPlacement for contain / cover
filtersSame ImageFilter[] pipeline as customBg
opacityStill-image alpha, multiplied by canvas opacity

If neither frame nor time is supplied, Apexify selects frame 1. Legacy loop and autoplay fields are deprecated because videoBg is a still-frame background, not video playback.

SOURCEtypescript
typescript
Studio
await painter.createCanvas({  width: 1920,  height: 1080,  videoBg: {    source: './clip.mp4',    time: 1.0,    fit: 'cover',    align: 'center',    filters: [{ type: 'contrast', value: 12 }],    format: 'jpg',    quality: 2,  },});

After the primary fill

You can still add bgLayers, patternBg, noiseBg on top — see the following pages.


Next steps