Node / Gif Animation · guide
onEnd, return values & cancellation
Current Apexify.js 6.0.0 documentation for onEnd, return values & cancellation.
onEnd
The runtime passes the active ApexPainter instance as the second argument.
finalFrameBuffer is a PNG snapshot of the last fully composited encoder canvas after frame sizing, watermarking, and textOverlay rendering. Use it for a poster/still preview or another derived static result.
onEnd runs only after GIF encoding has finished and the selected primary output has been drained/validated.
Return values
Without a static onEnd result:
outputFormat | Primary result |
|---|---|
buffer | GIF Buffer |
base64 | base64 string containing GIF bytes |
attachment | GIFAttachment[] with Buffer-backed .gif data and image/gif MIME |
file | undefined; file already written to outputFile |
If onEnd returns a Buffer:
buffer→{ gif: Buffer, static: Buffer }base64→{ gif: string, static: Buffer }attachment→{ gif: GIFAttachment[], static: Buffer }file→ the returned staticBufferonly; the GIF remains atoutputFile
Unlike the old attachment shortcut, Phase 7 does invoke onEnd for attachment output. Attachment creation drains and validates the encoder output first.
skipResizeWhenDimensionsMatch
Public sizing is always deterministic stretch-to-output.
| Value | Behaviour |
|---|---|
true or omitted | If decoded source dimensions already match output dimensions, draw directly without redundant sized scaling. |
false | Use the explicit sized draw path even when dimensions match. |
This is an optimization switch, not a fit/crop mode. Sources whose size differs from the GIF canvas are stretched to options.width × options.height in either case.
Cancellation (signal)
GIFOptions.signal accepts an AbortSignal.
A cancellation is checked before generated-frame startup and between frame pulls/processing steps, and is forwarded into remote media resolution. On failure/cancellation:
- no additional generated frames are requested;
- encoder/output streams are destroyed where applicable;
- pending output completion is observed to avoid unhandled stream failures;
- a partially written
outputFileis removed.
A signal that is already aborted prevents onStart from running.
Validation recap
Important Phase 7 rules include:
outputFormatmust befile,buffer,base64, orattachment.filerequires a non-emptyoutputFile.attachmentName, when present, must be a filename rather than a path.widthandheightmust be supplied together and fit GIF resource limits.repeatallows-1,0, or a finite positive repeat count within the encoder range.qualityis an integer from1through30.- frame/default delays must be finite and within the GIF delay range; zero delay is allowed.
- static frame lists must be non-empty and each frame must provide exactly one source.
- generated arrays/streams cannot exceed configured generated-frame/GIF limits.
- passing both a non-empty static list and
onStartis invalid.
Structured Apexify input/resource/network/decode/process errors are used for these failure classes rather than leaking arbitrary backend errors as the public contract.