Node / Raster Batch Output · guide
Resize, convert & effects
Current Apexify.js 6.0.0 documentation for Resize, convert & effects.
The raster helpers on painter.image now share the same image-source boundary used by canvas/image rendering. Supported sources are Buffer bytes, http(s): URLs, data:image/...;base64,... values, and filesystem paths. Image metadata is preflighted before decode against the configured source-byte, decoded-dimension, decoded-pixel, frame/page, and SVG-complexity limits. Remote inputs continue through the shared network policy rather than a helper-specific HTTP client.
This means resize, conversion, effects, color filtering, color analysis, masking, crop, and the other raster helpers no longer maintain separate ad-hoc filesystem/HTTP/canvas loaders.
resize(resizeOptions)
ResizeOptions:
| Field | Role |
|---|---|
imagePath | **`string |
size | Positive integer width / height. An omitted axis defaults to 500. The requested dimensions may enlarge the source. |
maintainAspectRatio | true uses Sharp inside/contain semantics; false uses fill and produces the exact requested dimensions. |
quality | Integer 1–100 for the selected encoder. |
outputFormat | png (default) or jpeg. The option is applied to the emitted bytes. |
EXIF orientation is applied before fitting, so portrait/landscape sizing uses the effective displayed dimensions rather than unrotated metadata.
Invalid, fractional, zero, over-limit, or otherwise unsafe target dimensions reject before the expensive resize work begins.
imgConverter(source, newExtension)
source is string | Buffer and uses the same metadata/decode preflight as resize.
Accepted extension names are jpeg, jpg, png, webp, tiff, gif, avif, heif, raw, jp2, and jxl. jpg is normalized to jpeg. Actual codec availability can still depend on the Sharp/libvips build used by the platform.
effects(source, filters)
effects resolves and caches the decoded source through the shared image pipeline, then applies the requested filter stack.
Legacy effect names remain supported for compatibility:
flip,rotate,brightness,contrast,invert,greyscale,sepia,blur,posterize,pixelate
The typed raster-filter pipeline is also supported:
grayscale,gaussianBlur,motionBlur,radialBlur,sharpen,noise,grain,edgeDetection,emboss,saturation,hueShift
Noise/grain operations are deterministic for reproducible renders, and the legacy blur path delegates to the shared native filter implementation instead of running a quadratic JavaScript blur loop.
Explicit zero values are preserved; for example, zero intensity is a no-op instead of being replaced with a default intensity.
colorsFilter(source, filterColor, opacity?)
Tint / wash using a CSS color string or GradientConfig. opacity is 0–1, and explicit 0 remains fully transparent.
Gradient stops must be finite, monotonic, and in 0–1. Linear/radial gradients support repeat: 'repeat' | 'reflect' | 'no-repeat'; reflect mirrors each adjacent period rather than merely repeating it.
colorAnalysis(source)
Returns a bounded dominant-color list in the historical { color, frequency }[] shape.
For large images the implementation metadata-preflights first, downsamples to at most 160×160, quantizes nearby RGB values, and returns at most 16 dominant colors. Transparent pixels are not emitted as colors; frequency keeps the compatibility denominator based on all sampled pixels.
colorsRemover(source, colorToRemove)
Removes one exact RGB color. Each channel is 0–255.
removeBackground(imageURL, apiKey)
Calls the remove.bg service through Apexify.js's bounded remote transport. The API key and remote service quotas remain external concerns.
validHex(hexColor)
Validates #RRGGBB and throws for invalid input.