Image Processing Toolkit for Node-RED
@rosepetal/node-red-contrib-image-tools provides 20 nodes for Node-RED that load, transform, compose, annotate, compare and save images. The image operations run in a native C++ addon built on OpenCV; loading and saving also use sharp.

Installation
cd ~/.node-red
npm install @rosepetal/node-red-contrib-image-toolsOr search @rosepetal/node-red-contrib-image-tools in the Node-RED Palette Manager.
npm fetches a prebuilt native addon, with OpenCV statically linked, for linux-x64 and linux-arm64 (glibc), linuxmusl-x64 (Alpine) and darwin-arm64. On any other platform the addon has to be built from source: see Building from source.
Requirements
- Node.js 18.17 or later (the
sharpdependency supports^18.17.0 || ^20.3.0 || >=21.0.0) - Node-RED >= 1.0.0
- One of the platforms above, or the tools to build the addon: OpenCV 4.x, a C++17 compiler and node-gyp
Nodes
All node types are prefixed with rp- and appear under the RP Image category in the editor. Flows saved with the earlier type names, without the prefix (resize, crop and so on), keep working: the published package also registers those names, hidden from the palette (every node except rp-heat-diff, which never had another name).
I/O
| Node | Purpose |
|---|---|
| rp-image-in | Load an image file from disk into the raw image object that the other nodes use |
| rp-folder-in | Emit the image files of a folder one by one at a set interval, in a loop or once, started and stopped with the node's button |
| rp-image-out | Save images to disk as JPEG, PNG, WebP or BMP, one per message or many from an array, with timestamped file names, overwrite protection, a file limit and a disk limit |
Transform
| Node | Purpose |
|---|---|
| rp-resize | Scale images to a fixed size or by a factor, keeping the aspect ratio when one dimension is left empty |
| rp-rotate | Rotate images by an angle in degrees and fill the uncovered area with a pad color |
| rp-crop | Extract a rectangular region, with normalized (0-1) or pixel coordinates |
| rp-padding | Add a margin of a solid color on each side |
| rp-filter | Apply blur, sharpening, edge detection, emboss, Gaussian blur, Otsu threshold, histogram equalization or CLAHE |
| rp-draw | Overlay points and line segments, with normalized coordinates, color and opacity |
| rp-color-convert | Convert images between the GRAY, RGB, RGBA, BGR and BGRA color spaces |
Mix
| Node | Purpose |
|---|---|
| rp-concat | Join an array of images into one, to the right, left, down or up, padding or resizing the ones that differ in size |
| rp-mosaic | Place the images of an array on a canvas at the positions set in the node, in pixels or normalized coordinates |
| rp-advanced-mosaic | Compose the images of an array on a canvas with a position, size, rotation and stacking order per image, set in a visual editor |
Blend
| Node | Purpose |
|---|---|
| rp-blend | Blend two images with an adjustable opacity, with optional alpha compositing and background color removal |
| rp-add-mask | Blend a polygon mask over an image, from normalized polygon coordinates, with a fill color and a strength |
| rp-add-masks | Blend several polygon or bitmap masks over an image, with a color per class |
| rp-add-bbs | Draw bounding boxes on an image, labelled with their tag and confidence, with a color per tag |
Specialized
| Node | Purpose |
|---|---|
| rp-cropBB | Extract one crop per bounding box of an inference result, filtered by a minimum confidence |
| rp-image-align | Align a target image to a reference image with ECC, with ORB or SIFT features, or with features refined by ECC |
| rp-heat-diff | Compute the per-pixel absolute difference of two images as a color-mapped heat image, with optional difference statistics |
Quick start
[inject] → [rp-image-in] → [rp-resize] → [rp-image-out]- In
rp-image-in, set File Path to an image file on the Node-RED host. Any incoming message makes the node load the file intomsg.payload. - In
rp-resize, set Width and leave Height empty to keep the aspect ratio. - In
rp-image-out, set Folder Path. With the default settings the image is saved there asimage_<timestamp>.jpg.
Image format
The nodes pass raw images between them as objects:
{
data: Buffer, // Raw pixel data
width: number, // Image width in pixels
height: number, // Image height in pixels
channels: number, // Channel count (1, 3, 4)
colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
dtype: string // "uint8"
}rp-image-in and rp-folder-in produce this object, with colorSpace GRAY, RGB or RGBA. A raw image without colorSpace is read as GRAY, RGB or RGBA from its channel count; a colorSpace that does not match the channel count is rejected. The transform, mix, blend and specialized nodes (except rp-cropBB) also accept an encoded JPEG, PNG, WebP or BMP Buffer in its place and decode it in the addon (as RGB, RGBA or GRAY); rp-image-out accepts JPEG, PNG and WebP buffers.
Common settings
The transform, mix, blend and specialized nodes share these settings:
- Input from / Output to: where the image is read and where the result is written, as a
msgproperty or aflow/globalcontext key. The result goes tomsg.payloadby default. The nodes that read two inputs or extra data (rp-blend,rp-add-mask,rp-add-masks,rp-add-bbs,rp-cropBB,rp-image-alignandrp-heat-diff) read and writemsgproperties only (except Stats to ofrp-heat-diff), although their editor also offersflowandglobal. - Output Format:
raw(the image object, the default) or an encodedBufferinjpg,pngorwebp. Quality (1-100, default 90) applies to JPEG and WebP; PNG Optimize sets PNG compression level 6 instead of 0; the WebP options Lossless, Smart Subsample and Effort (0-6) makesharpencode the WebP instead of OpenCV. JPEG drops the alpha channel. - Debug: shows a preview of the result in the editor, with a configurable width (200 pixels by default).
- Inference (
rp-resize,rp-rotate,rp-crop,rp-padding,rp-concat,rp-mosaicandrp-advanced-mosaic, under Advanced options): when checked, the detections and segmentations read frommsg.inference(by default) get the same geometric change as the image and are written back, so that their coordinates match the output image (forrp-advanced-mosaic, not for every rotated or one-side-resized placement: see its page). Detections are objects withraw_boxes(four normalized corner points) and segmentations objects withpolygons(normalized points); other entries pass unchanged. For the nodes that combine several images,msg.inferenceholds one such array per input image and the result is a single array.
rp-resize, rp-rotate, rp-crop, rp-padding, rp-filter and rp-color-convert take one image or an array of images, and process the images of an array in parallel. rp-image-align and rp-heat-diff take two images or two arrays of the same length, paired by index.
Timing and errors
The transform, mix, blend and specialized nodes, and rp-folder-in, record their processing time in msg.performance.rpimage.<key> as { conversion, task, total }, in milliseconds. <key> is the name of the node, or its type when it has no name, in lower case and with every run of other characters replaced by _ (rp_resize).
When the processing fails, the transform, mix, blend and specialized nodes do not stop the flow: they set msg.error (message, operation, hint, details, timestamp, nodeId, nodeName, nodeType, and validationError: true when the input was rejected), log a warning, show a red Error: ... status and still send the message. The I/O nodes behave differently: see their pages.
Performance
- Decoding, processing and encoding run on the libuv thread pool, not on the Node-RED event loop; the JavaScript layer only validates and routes messages.
- The pool has 4 threads by default and is shared with
sharpand file I/O. Under heavy concurrency, raise it before starting Node-RED:UV_THREADPOOL_SIZE=8 node-red. - Keep the
rawoutput format between the nodes of a chain and encode only at the end.
Building from source
For contributors, and for platforms without a prebuilt addon:
git clone https://github.com/rosepetal-ai/node-red-contrib-image-tools.git
cd node-red-contrib-image-tools
./install.shThe script installs the build tools and OpenCV with the system's package manager (apt, dnf, yum, pacman or Homebrew) when pkg-config does not find OpenCV 4, builds the C++ addon, and offers to install the package into ~/.node-red.
Related packages
Several examples in these pages collect images into an array with Array-In and Array-Out nodes. They are rp-array-in and rp-array-out, which moved from this package to @rosepetal/node-red-contrib-utils.
License
Apache-2.0. The package is published on npm as @rosepetal/node-red-contrib-image-tools.