Node / Raster Batch Output · guide
Save to disk
Current Apexify.js 6.0.0 documentation for Save to disk.
await painter.save(buffer, options?) and await painter.saveMultiple(buffers, options?) write image bytes to disk, optionally transcode with Sharp (JPEG / WebP / AVIF). Session state: a per-painter saveCounter (starts at 1) increments for naming: 'counter' (lib-next/output/save-buffer.ts, SaveOptions lib-next/types/output.ts).
resetSaveCounter is not exposed on lib-next ApexPainter — create a new painter or control names with filename, timestamp, or custom naming.
save(buffer, options?)
SOURCEtypescript
typescript
SaveOptions
| Field | Default | Notes |
|---|---|---|
directory | ./ApexPainter_output | Created when createDirectory (default true). |
filename | — | If set and has no extension, .${format} appended. |
format | png | png writes buffer as-is; other formats pipe through Sharp. |
quality | 90 | JPEG / WebP / AVIF quality. |
createDirectory | true | mkdir -p semantics. |
naming | timestamp | timestamp **` |
counterStart | 1 | Merged into options in saveMultiple; counter mode still uses session.saveCounter internally (see behaviour below). |
prefix / suffix | "" | Applied to generated names. |
overwrite | false | When false, appends _1, _2, … before extension if path exists. |
SaveResult
{ path, filename, size, format }
Naming modes
| Mode | Filename pattern |
|---|---|
timestamp | prefix + YYYYMMDD_HHMMSS_mmm + suffix + .format |
counter | prefix + live saveCounter + suffix + .format, then saveCounter++ |
custom | prefix + suffix + .format (empty base if both blank). |
saveMultiple(buffers, options?)
SOURCEtypescript
typescript
- Requires a non-empty array.
- Iterates
saveImageBufferper entry. Fornaming: 'counter', the session counter advances once per file (sequential1,2,3, … from the shared session).
Formats & Sharp
png: direct write (no Sharp re-encode).jpg/jpeg,webp,avif:require('sharp')must be available at runtime.gif: special-cased (non-GIF input logs a warning; buffer may pass through unchanged).
Example
SOURCEtypescript
typescript