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

Node / Gif Animation · reference

Canvas size, encoder & output formats

Current Apexify.js 6.0.0 documentation for Canvas size, encoder & output formats.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Dimensions

FieldDefaultRole
width1200GIF encoder canvas width.
height1200GIF encoder canvas height.

width and height must be supplied together when either is provided. The dimensions are checked against the central GIF dimension/resource-cost limits before encoding work proceeds.

Every resolved frame is cleared into and drawn onto this output canvas. Sources with different dimensions are stretched to the configured output dimensions. Exact-size sources can skip redundant scaling when skipResizeWhenDimensionsMatch is omitted or true.


Encoder tuning

FieldDefaultRole
repeat0Repeat mode: -1 = play once, 0 = loop indefinitely, positive values = finite repeat count.
quality10Quantizer sample interval 1…30. Lower values improve color mapping at higher CPU cost.
delay100 ms fallbackUsed when a frame omits its own duration.

A provided delay must be finite and within the encoder-supported range. GIF timing is represented in 10 ms units internally.

frameCount and duration can provide bounds/hints for generated-frame mode. They do not permit a producer to exceed central maxGifFrames or aggregate GIF resource limits.


outputFormat (required)

ValueBehaviour
fileStreams encoded bytes to outputFile (required), waits for the file stream to finish, validates the GIF signature, then resolves undefined unless onEnd returns a static image. Partial files are removed on failure.
bufferFully drains the encoder stream and returns a GIF Buffer after signature validation.
base64Fully drains the encoder stream, validates it, then returns buffer.toString('base64'). No data-URL prefix is added.
attachmentFully drains and validates the encoder stream, then returns GIFAttachment[] containing Buffer-backed GIF bytes, a .gif filename, and contentType: 'image/gif'.

Unsupported output strings are rejected by validation.

Attachment naming

attachmentName is optional and must be a filename, not a path. Default: image.gif. If the supplied name does not already end in .gif, Apexify appends the extension.

SOURCEtypescript
typescript
Studio
const attachments = await painter.createGIF(frames, {  outputFormat: 'attachment',  attachmentName: 'status-animation',  width: 640,  height: 360,}); // [{ attachment: Buffer, name: 'status-animation.gif', contentType: 'image/gif' }]

File example

SOURCEtypescript
typescript
Studio
await painter.createGIF(frames, {  outputFormat: 'file',  outputFile: './out/animation.gif',  width: 640,  height: 360,  repeat: 0,  quality: 8,  delay: 80,});

The method resolves only after the file output has finished and passed the GIF signature check.

Next steps