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.
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
Default: buffer.
await painter.toOutput(results)
Input must be a non-empty Buffer, normally PNG bytes produced by Apexify.
type | Return |
|---|---|
buffer | The original Buffer. |
base64 | Raw Base64 string with no data: prefix. |
dataURL | data:image/png;base64,…. |
blob | Blob containing exactly the supplied bytes, with PNG MIME when using the painter output path. |
arraybuffer | ArrayBuffer containing exactly the supplied byte slice. A sliced Node Buffer does not expose unrelated bytes from its larger backing allocation. |
url | Promise<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:
These helpers ignore constructor type.
Base64 vs data URL
These are deliberately different contracts:
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_IDIMGUR_CLIENT_SECRETIMGUR_ACCESS_TOKENIMGUR_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
| Goal | Approach |
|---|---|
| Keep buffers everywhere | new ApexPainter() and use returned buffers. |
| Encode ad hoc | painter.output.*. |
One global encoding for toOutput | new ApexPainter({ type: '…' }), then await painter.toOutput(buf). |
| Maintain older callers | painter.outPut(buf) remains a deprecated compatibility alias. |
| Save to disk safely | save / saveMultiple with explicit SaveOptions. |