Node / Raster Batch Output · guide
Blend, mask, crop & gradient
Current Apexify.js 6.0.0 documentation for Blend, mask, crop & gradient.
These painter.image helpers share the same bounded image-source/decode pipeline used by canvas rendering. Local files, bytes, data URLs, and remote images are resolved through one policy; metadata limits and SVG restrictions are applied before expensive raster work.
blend(layers, baseImageBuffer, defaultBlendMode?)
Stacks ImageBlendLayer entries over a baseImageBuffer. Layer order is deterministic: array index 0 is composited first, later entries are painted above it. Optional layer opacity preserves explicit 0.
cropImage(options)
cropImage uses the shared source validator/cache and then applies either an axis-aligned inner crop or an outer punch-out path.
Coordinate rules
- At least 3 coordinate rows are required.
- Every
from.x,from.y,to.x, andto.ymust be finite and non-negative. 0is valid for both axes.- Coordinates that exceed the decoded source width/height reject instead of relying on backend clipping.
- A degenerate inner crop with zero width or height rejects.
crop: 'inner'
Every from/to point contributes to the minimum/maximum X/Y values. Those extrema form the rectangular output region. Optional numeric radius rounds the crop rectangle; radius: 'circular' clips it to the largest centered circle that fits.
crop: 'outer'
The source dimensions are preserved. The coordinate path is filled using destination-out, producing a transparent hole while leaving pixels outside the path untouched. tension influences the Bézier control points.
masking(source, maskSource, options?)
Both the source and mask pass through the shared image-source policy and decoded-image cache. The output uses the source dimensions; the mask is fitted to those dimensions before mask values are applied.
MaskOptions:
| Field | Meaning |
|---|---|
type | alpha (default), grayscale, or color |
threshold | Grayscale cutoff 0–255 |
colorKey | Required with type: 'color', formatted as #RRGGBB |
invert | Inverts the resulting mask alpha |
Invalid mask modes/options use Apexify.js structured input/decode errors rather than generic helper-specific exceptions.
gradientBlend(source, options)
BlendOptions supports linear, radial, and conic gradients plus the documented blend modes. Gradient stop validation is shared with the rest of the rendering pipeline, so stops must be finite, monotonic, and within 0–1.
Composition mindset
Use these helpers when you need a transformed raster before or between larger canvas/scene composition steps. Because the source resolver, decoder limits, cache, and structured validation are shared, the same safety/resource behavior applies whether the image is used directly or later placed into a scene.