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

Node / Raster Batch Output · guide

Constructor output type, toOutput, legacy outPut & painter.output

Current Apexify.js 6.0.0 documentation for Constructor output type, toOutput, legacy outPut & painter.output.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Rendering does not depend on constructor type. Canvas, image, chart, scene, batch, and chain paths build raster data the same way and expose Buffer values (or structures containing .buffer). The constructor OutputFormat.type is consumed by await painter.toOutput(buffer) through bufferToPainterOutput. The older await painter.outPut(buffer) spelling remains as a deprecated compatibility alias and delegates to toOutput.

Most applications should keep new ApexPainter() with the default buffer output and use explicit painter.output.* helpers when another representation is needed.


Optional constructor OutputFormat

SOURCEtypescript
typescript
Studio
new ApexPainter({  type?: 'buffer' | 'url' | 'blob' | 'base64' | 'dataURL' | 'arraybuffer'});

Default: buffer.


await painter.toOutput(results)

Input must be a non-empty Buffer, normally PNG bytes produced by Apexify.

typeReturn
bufferThe original Buffer.
base64Raw Base64 string with no data: prefix.
dataURLdata:image/png;base64,….
blobBlob containing exactly the supplied bytes, with PNG MIME when using the painter output path.
arraybufferArrayBuffer containing exactly the supplied byte slice. A sliced Node Buffer does not expose unrelated bytes from its larger backing allocation.
urlPromise<string> that uploads PNG bytes through the Imgur integration.

Unsupported constructor output types reject with the allowed values.

save / saveMultiple are separate disk-output APIs and do not use constructor type.

Legacy outPut alias

await painter.outPut(results) is retained for existing Apexify.js applications and returns the same result as toOutput. New code should use toOutput; outPut is deprecated rather than removed so the naming cleanup does not break established callers.


painter.output

The explicit output facet provides:

SOURCEtypescript
typescript
Studio
painter.output.dataURL(buffer)painter.output.base64(buffer)painter.output.blob(buffer)painter.output.arrayBuffer(buffer)await painter.output.url(buffer, credentials?)

These helpers ignore constructor type.

SOURCEtypescript
typescript
Studio
import { ApexPainter } from 'apexify.js'; const painter = new ApexPainter();const { buffer } = await painter.createCanvas({  width: 64,  height: 64,  colorBg: '#111827',}); const converted = await painter.toOutput(buffer);const dataUrl = painter.output.dataURL(buffer);const b64 = painter.output.base64(buffer);const bytes = painter.output.arrayBuffer(buffer);

Base64 vs data URL

These are deliberately different contracts:

SOURCEtypescript
typescript
Studio
painter.output.base64(buffer);  // "iVBORw0KGgo..."painter.output.dataURL(buffer); // "data:image/png;base64,iVBORw0KGgo..."

Do not strip or add prefixes manually unless another API explicitly requires that representation.

Imgur credentials

Apexify contains no embedded Imgur credentials. painter.output.url() requires either caller-supplied credentials or the documented environment variables:

  • IMGUR_CLIENT_ID
  • IMGUR_CLIENT_SECRET
  • IMGUR_ACCESS_TOKEN
  • IMGUR_REFRESH_TOKEN

If required credentials are absent, the call rejects before an upload request is attempted. Credentials are not logged by Apexify.


Disk save behavior

save and saveMultiple use asynchronous filesystem operations. With overwrite: false, filename collision handling uses exclusive file creation so concurrent writers cannot silently overwrite the same path. A collision advances to a suffixed filename such as image_1.png.


Practical takeaway

GoalApproach
Keep buffers everywherenew ApexPainter() and use returned buffers.
Encode ad hocpainter.output.*.
One global encoding for toOutputnew ApexPainter({ type: '…' }), then await painter.toOutput(buf).
Maintain older callerspainter.outPut(buf) remains a deprecated compatibility alias.
Save to disk safelysave / saveMultiple with explicit SaveOptions.

Next steps