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

Node / Images Shapes · guide

createImage basics — source, placement & fit

Current Apexify.js 6.0.0 documentation for createImage basics — source, placement & fit.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Required fields

Every ImageProperties entry must include:

FieldTypeNotes
source**`stringBuffer
xnumberTop-left of the layout box (unless overridden by shape-specific geometry).
ynumberSame.

If source, x, or y is missing, ImageCreator throws.


Bitmap sizing — width, height, inherit

After the image loads, the layout box size is:

SituationWidth / height used
inherit: true and width omittedIntrinsic image width
inherit: true and height omittedIntrinsic image height
Otherwise width/height omittedAlso falls back to intrinsic size
Explicit width/heightForces box dimensions

Use inherit when you want “natural” pixels but still allow fit / align inside an explicit box.


Fit & align — how bitmaps land in the box

FitMode is 'fill' | 'contain' | 'cover' — exported from apexify.js alongside AlignMode.

ModeBehaviour
fillStretches to exactly width × height
containUniform scale so the whole image fits inside the box (may letterbox)
coverUniform scale so the box is fully covered (may crop)

AlignMode covers center, top, bottom, left, right, and corners (top-left, …). align only matters when contain leaves empty margins.

SOURCEtypescript
typescript
Studio
await painter.createImage(  {    source: './photo.jpg',    x: 0,    y: 0,    width: 400,    height: 300,    fit: 'contain',    align: 'bottom-right',  },  buffer);

Next steps