Node / Raster Batch Output · guide
Compress & palette
Current Apexify.js 6.0.0 documentation for Compress & palette.
Sharp-backed helpers exposed as await painter.image.compress(image, options?) and await painter.image.extractPalette(image, options?) (lib-next/output/compression.ts).
Sources:** Buffer, http(s) URL, or filesystem path (**joined with process.cwd() when not absolute / URL).
compress(image, options?)
CompressionOptions
| Field | Default | Notes |
|---|---|---|
quality | 90 | Passed to jpeg, webp, avif pipelines. |
format | jpeg | jpeg **` |
maxWidth / maxHeight | — | fit: 'inside', withoutEnlargement: true. |
progressive | false | JPEG progressive scan. |
Returns encoded Buffer (not necessarily PNG).
SOURCEtypescript
typescript
extractPalette(image, options?)
Downsamples internally to ~200×200 raw RGB, then clusters.
PaletteOptions
| Field | Default | Notes |
|---|---|---|
count | 10 | Target swatch count (algorithms clamp / approximate). |
method | kmeans | kmeans (iterative) **` |
format | hex | hex **` |
Return shape
Array<{ color: string; percentage: number }> sorted descending by percentage.
SOURCEtypescript
typescript
Operational notes
- Network
/disk IO failures surface ascompress failed:/extractPalette failed:wraps. extractPalettepercentagederives from clustered pixel assignments vs total sample count (see implementation for details).