@rosepetal/node-red-contrib-image-tools 1.6.4 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/rules/node-implementation-template.md +1 -1
- package/.github/workflows/build-prebuild.yml +1 -1
- package/README.md +41 -21
- package/docs/index.md +156 -0
- package/docs/nodes/blend/add-bbs.md +116 -0
- package/docs/nodes/blend/add-mask.md +67 -224
- package/docs/nodes/blend/add-masks.md +74 -196
- package/docs/nodes/blend/blend.md +84 -200
- package/docs/nodes/io/folder-in.md +92 -0
- package/docs/nodes/io/image-in.md +61 -52
- package/docs/nodes/io/image-out.md +114 -93
- package/docs/nodes/mix/advanced-mosaic.md +124 -78
- package/docs/nodes/mix/concat.md +71 -56
- package/docs/nodes/mix/mosaic.md +81 -91
- package/docs/nodes/specialized/cropBB.md +76 -214
- package/docs/nodes/specialized/heat-diff.md +111 -0
- package/docs/nodes/specialized/image-align.md +125 -387
- package/docs/nodes/transform/color-convert.md +101 -0
- package/docs/nodes/transform/crop.md +56 -58
- package/docs/nodes/transform/draw.md +46 -26
- package/docs/nodes/transform/filter.md +110 -46
- package/docs/nodes/transform/padding.md +55 -55
- package/docs/nodes/transform/resize.md +81 -56
- package/docs/nodes/transform/rotate.md +67 -50
- package/node-red-contrib-image-tools/lib/bmp-decode.js +18 -68
- package/node-red-contrib-image-tools/lib/cpp-bridge.js +202 -104
- package/node-red-contrib-image-tools/lib/node-utils.js +78 -78
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +98 -46
- package/node-red-contrib-image-tools/nodes/io/image-in.js +3 -4
- package/node-red-contrib-image-tools/nodes/io/image-out.js +93 -146
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +3 -3
- package/node-red-contrib-image-tools/nodes/specialized/heat-diff.js +3 -3
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +11 -4
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +5 -4
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +3 -3
- package/node-red-contrib-image-tools/nodes/transform/crop.js +3 -3
- package/node-red-contrib-image-tools/nodes/transform/filter.js +3 -3
- package/node-red-contrib-image-tools/nodes/transform/padding.js +3 -3
- package/node-red-contrib-image-tools/nodes/transform/resize.js +3 -3
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +3 -3
- package/npm/darwin-arm64/package.json +1 -1
- package/npm/darwin-x64/package.json +1 -1
- package/npm/linux-arm64/package.json +1 -1
- package/npm/linux-x64/package.json +1 -1
- package/npm/linuxmusl-x64/package.json +1 -1
- package/npm/win32-x64/package.json +1 -1
- package/package.json +6 -6
- package/rosepetal-image-engine/binding.gyp +2 -1
- package/rosepetal-image-engine/src/add-bbs.cpp +123 -123
- package/rosepetal-image-engine/src/add-mask.cpp +30 -15
- package/rosepetal-image-engine/src/add-masks.cpp +145 -102
- package/rosepetal-image-engine/src/advanced-mosaic.cpp +200 -129
- package/rosepetal-image-engine/src/blend.cpp +34 -20
- package/rosepetal-image-engine/src/codec.cpp +157 -0
- package/rosepetal-image-engine/src/color-convert.cpp +22 -19
- package/rosepetal-image-engine/src/concat.cpp +38 -43
- package/rosepetal-image-engine/src/crop.cpp +23 -26
- package/rosepetal-image-engine/src/draw.cpp +33 -10
- package/rosepetal-image-engine/src/filter.cpp +22 -26
- package/rosepetal-image-engine/src/heat-diff.cpp +35 -8
- package/rosepetal-image-engine/src/image-align.cpp +107 -35
- package/rosepetal-image-engine/src/main.cpp +4 -0
- package/rosepetal-image-engine/src/mosaic.cpp +31 -40
- package/rosepetal-image-engine/src/padding.cpp +30 -29
- package/rosepetal-image-engine/src/resize.cpp +20 -25
- package/rosepetal-image-engine/src/rotate.cpp +22 -23
- package/rosepetal-image-engine/src/utils.h +243 -144
- package/scripts/build-opencv-static.sh +6 -0
- package/scripts/dual-register.js +32 -25
- package/scripts/sync-version.js +58 -41
package/docs/nodes/mix/concat.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Concat Node - Join Images Side by Side or Stacked"
|
|
3
|
+
description: "Join an array of images into one image in Node-RED, to the right, left, down or up, padding or resizing the ones that differ in size. Part of @rosepetal/node-red-contrib-image-tools."
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: "keywords"
|
|
7
|
+
content: "node-red, concat, concatenate images, image strip, side by side, opencv, rosepetal"
|
|
8
|
+
- - meta
|
|
9
|
+
- property: "og:title"
|
|
10
|
+
content: "Concat Node - @rosepetal/node-red-contrib-image-tools"
|
|
11
|
+
- - meta
|
|
12
|
+
- property: "og:description"
|
|
13
|
+
content: "Join an array of images into one image in Node-RED, to the right, left, down or up, padding or resizing the ones that differ in size."
|
|
14
|
+
---
|
|
15
|
+
|
|
1
16
|
# Concat Node
|
|
2
17
|
|
|
3
18
|
## Purpose & Use Cases
|
|
4
19
|
|
|
5
|
-
The `concat` node
|
|
20
|
+
The `concat` node joins the images of an array side by side or one above the other into a single image. Images of different height (or width) are padded with a colour or scaled to match.
|
|
6
21
|
|
|
7
22
|
**Real-World Applications:**
|
|
8
23
|
- **Before/After Comparisons**: Side-by-side image comparisons for treatments, edits, or changes
|
|
@@ -16,112 +31,112 @@ The `concat` node combines multiple images horizontally or vertically into a sin
|
|
|
16
31
|
## Input/Output Specification
|
|
17
32
|
|
|
18
33
|
### Inputs
|
|
19
|
-
- **Image Array**:
|
|
34
|
+
- **Image Array**: an array of raw image objects or encoded JPEG/PNG/WebP/BMP `Buffer`s, read from **Input** (`msg.payload` by default). A single image is treated as an array of one.
|
|
35
|
+
- The images may have different sizes and color spaces. They are all converted to one color space before joining: RGBA if any image is RGBA, else BGRA, RGB, BGR and GRAY, in that order.
|
|
20
36
|
|
|
21
37
|
### Outputs
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
38
|
+
One output:
|
|
39
|
+
- **Combined Image**: one image, written to **Output** (`msg.payload` by default), as a raw image object or an encoded `Buffer` (JPEG/PNG/WebP)
|
|
40
|
+
- **Dimensions**: joining to the right or left, the width is the sum of the widths (the scaled widths with Resize to max) and the height the largest height; joining down or up, the other way round
|
|
41
|
+
- `msg.performance.rpimage.<key>`: `{ conversion, task, total }` in milliseconds
|
|
25
42
|
|
|
26
43
|
## Configuration Options
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
| Property | Default | Meaning |
|
|
46
|
+
|----------|---------|---------|
|
|
47
|
+
| Input | `msg.payload` | Where the array is read (`msg`, `flow` or `global`) |
|
|
48
|
+
| Output | `msg.payload` | Where the joined image is written (`msg`, `flow` or `global`) |
|
|
49
|
+
| Output Format | Raw (fastest) | Raw (fastest), JPEG, PNG or WebP, with Quality (`90`), PNG Optimize and the WebP options as in [resize](../transform/resize.md#output-format-options) |
|
|
50
|
+
| Debug / Debug Width | off / `200` | **Show processed image** under the node in the editor |
|
|
51
|
+
| Direction | → Right | → Right, ← Left, ↓ Down or ↑ Up |
|
|
52
|
+
| Strategy | Pad at start | How images of a different height (or width) are matched: Pad at start, Pad at end, Pad both sides or Resize to max |
|
|
53
|
+
| Pad colour | `#000000` | Colour of the padding |
|
|
54
|
+
| Inference | off | Under **Advanced options**: **Transform inference coordinates**, with **Inf. Input** and **Inf. Output** (both `msg.inference`) |
|
|
55
|
+
|
|
56
|
+
The editor has no Name field for this node, so its timings are recorded under `msg.performance.rpimage.rp_concat`.
|
|
31
57
|
|
|
32
58
|
### Direction Options
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
59
|
+
- **→ Right**: Images arranged left-to-right in array order
|
|
60
|
+
- **← Left**: the → Right result mirrored horizontally: the first image ends up on the right, and every image is mirrored too
|
|
61
|
+
- **↓ Down**: Images stacked top-to-bottom in array order
|
|
62
|
+
- **↑ Up**: Images stacked bottom-to-top (the first image at the bottom), not mirrored
|
|
37
63
|
|
|
38
64
|
### Strategy Options
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- **
|
|
42
|
-
- **
|
|
43
|
-
- **
|
|
44
|
-
- **resize**: Resize all images to match largest dimension
|
|
65
|
+
For a horizontal join the strategies act on the height; for a vertical join, on the width.
|
|
66
|
+
- **Pad at start**: padding above (or to the left of) the smaller images
|
|
67
|
+
- **Pad at end**: padding below (or to the right of) the smaller images
|
|
68
|
+
- **Pad both sides**: the smaller images centred, with padding on both sides
|
|
69
|
+
- **Resize to max**: every image scaled, keeping its aspect ratio, to the largest height (or width)
|
|
45
70
|
|
|
46
71
|
### Color Configuration
|
|
47
|
-
- **
|
|
48
|
-
-
|
|
49
|
-
- **Formats**: RGB (`rgb(255,0,0)`)
|
|
72
|
+
- **Pad colour**: picked with the editor's colour picker (`#RRGGBB`); default black
|
|
73
|
+
- When the joined image has alpha (RGBA, BGRA), the padding is transparent
|
|
50
74
|
|
|
51
|
-
###
|
|
52
|
-
|
|
53
|
-
- **JPEG**: Compressed with quality control
|
|
54
|
-
- **PNG**: Lossless with transparency support
|
|
55
|
-
- **WebP**: Modern format with excellent compression
|
|
75
|
+
### Inference
|
|
76
|
+
With **Transform inference coordinates** checked, **Inf. Input** must hold an array with one entry per input image, each the inference array of that image. The node maps every detection (with `raw_boxes`) and segmentation polygon into the joined image and writes a single flat array to **Inf. Output**; other entries are copied unchanged and bitmap masks are not transformed. The image sizes are read from the raw image objects: with encoded `Buffer` inputs the coordinates come out as `NaN`.
|
|
56
77
|
|
|
57
|
-
##
|
|
78
|
+
## Status and Errors
|
|
58
79
|
|
|
59
|
-
|
|
60
|
-
- **
|
|
61
|
-
- **Alignment Algorithms**: Fast positioning calculations for different alignment modes
|
|
62
|
-
- **Batch Processing**: All images processed in single operation
|
|
63
|
-
- **Memory Management**: Minimal copying with direct canvas placement
|
|
80
|
+
- **Success**: green dot `OK: 1 img in <t> ms (conv <c> ms | task <k> ms)` (one joined image), plus the preview format with Debug on
|
|
81
|
+
- **Failure**: `msg.error` is set, the **first** input image is written to **Output**, a warning is logged, the status shows a red ring `Error: <first 30 characters>` and the message is still sent. An invalid array gives `Invalid image list`
|
|
64
82
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
- **Memory Efficiency**: Pre-calculates final dimensions to minimize allocations
|
|
83
|
+
## Performance Notes
|
|
84
|
+
|
|
85
|
+
- The images are converted, padded or scaled and joined in one call to the native OpenCV addon, on the libuv thread pool
|
|
69
86
|
|
|
70
87
|
## Real-World Examples
|
|
71
88
|
|
|
72
89
|
### Before/After Comparison
|
|
73
90
|
```
|
|
74
91
|
[Original Image] → [Array-In: pos=0] ┐
|
|
75
|
-
[Processed Image] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Right, Strategy=
|
|
92
|
+
[Processed Image] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Right, Strategy=Pad both sides] → [Comparison Strip]
|
|
76
93
|
```
|
|
77
|
-
Create side-by-side before/after comparisons with centered alignment.
|
|
94
|
+
Create side-by-side before/after comparisons with centered alignment. Array-In and Array-Out, used in these examples to build the array, are part of [`@rosepetal/node-red-contrib-utils`](https://docs.rosepetal.ai/flows/node-red-contrib-utils/nodes/io/array-in).
|
|
78
95
|
|
|
79
96
|
### Product Catalog Strip
|
|
80
97
|
```
|
|
81
|
-
[Product Photos Array] → [Concat: Direction=Right, Strategy=
|
|
98
|
+
[Product Photos Array] → [Concat: Direction=Right, Strategy=Resize to max] → [Catalog Strip]
|
|
82
99
|
```
|
|
83
100
|
Combine multiple product views, resizing to uniform height.
|
|
84
101
|
|
|
85
102
|
### Progress Timeline
|
|
86
103
|
```
|
|
87
104
|
[Step 1 Image] → [Array-In: pos=0] ┐
|
|
88
|
-
[Step 2 Image] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Down, Strategy=
|
|
105
|
+
[Step 2 Image] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Down, Strategy=Pad both sides] → [Process Timeline]
|
|
89
106
|
[Step 3 Image] → [Array-In: pos=2] ┘
|
|
90
107
|
```
|
|
91
108
|
Document multi-step processes vertically with centered alignment.
|
|
92
109
|
|
|
93
110
|
### Social Media Carousel
|
|
94
111
|
```
|
|
95
|
-
[Image Array] → [Resize:
|
|
112
|
+
[Image Array] → [Resize: Height=Set to 600, Width empty] → [Concat: Direction=Right, Strategy=Pad at start] → [Carousel Image]
|
|
96
113
|
```
|
|
97
114
|
Create horizontal image strips for social media.
|
|
98
115
|
|
|
99
116
|
### Report Layout
|
|
100
117
|
```
|
|
101
118
|
[Chart Image] → [Array-In: pos=0] ┐
|
|
102
|
-
[Photo Evidence] → [Array-In: pos=1] ├→ [Array-Out] → [Concat:
|
|
119
|
+
[Photo Evidence] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Down] → [Report Section]
|
|
103
120
|
[Data Table] → [Array-In: pos=2] ┘
|
|
104
121
|
```
|
|
105
|
-
Combine different types of visual content into reports.
|
|
122
|
+
Combine different types of visual content into reports (Direction ↓ Down).
|
|
106
123
|
|
|
107
124
|
## Common Issues & Troubleshooting
|
|
108
125
|
|
|
109
126
|
### Dimension Mismatches
|
|
110
|
-
- **Issue**: Images with different sizes
|
|
111
|
-
- **Solution**:
|
|
112
|
-
|
|
127
|
+
- **Issue**: Images with different sizes leave padded bands
|
|
128
|
+
- **Solution**: Choose **Resize to max**, or use a [resize](../transform/resize.md) node to standardize dimensions before concat
|
|
129
|
+
|
|
130
|
+
### Mirrored Images
|
|
131
|
+
- **Issue**: With **← Left** the images come out mirrored
|
|
132
|
+
- **Cause**: The node mirrors the whole joined image to reverse the order
|
|
133
|
+
- **Solution**: Reverse the array before the node and use **→ Right**
|
|
113
134
|
|
|
114
135
|
### Memory Usage with Large Images
|
|
115
136
|
- **Issue**: Concatenating many large images uses significant memory
|
|
116
137
|
- **Solution**: Resize images to appropriate sizes before concatenation
|
|
117
|
-
- **Monitoring**: Watch memory usage with large image arrays
|
|
118
|
-
|
|
119
|
-
### Aspect Ratio Problems
|
|
120
|
-
- **Issue**: Combined image has awkward proportions
|
|
121
|
-
- **Planning**: Consider final aspect ratio when planning image arrangement
|
|
122
|
-
- **Solution**: Use padding or cropping to improve final composition
|
|
123
138
|
|
|
124
|
-
###
|
|
125
|
-
- **Issue**:
|
|
126
|
-
- **
|
|
127
|
-
- **Solution**:
|
|
139
|
+
### Unexpected Transparency
|
|
140
|
+
- **Issue**: Padding is transparent instead of the pad colour
|
|
141
|
+
- **Cause**: One RGBA image makes the whole result RGBA, and padding on an image with alpha is transparent
|
|
142
|
+
- **Solution**: Convert the images to RGB first with [color-convert](../transform/color-convert.md)
|
package/docs/nodes/mix/mosaic.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Mosaic Node - Place Images on a Canvas"
|
|
3
|
+
description: "Place the images of an array on a canvas in Node-RED at the positions set in the node, in pixels or normalized coordinates. Part of @rosepetal/node-red-contrib-image-tools."
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: "keywords"
|
|
7
|
+
content: "node-red, mosaic, canvas, image composition, collage, positioning, opencv, rosepetal"
|
|
8
|
+
- - meta
|
|
9
|
+
- property: "og:title"
|
|
10
|
+
content: "Mosaic Node - @rosepetal/node-red-contrib-image-tools"
|
|
11
|
+
- - meta
|
|
12
|
+
- property: "og:description"
|
|
13
|
+
content: "Place the images of an array on a canvas in Node-RED at the positions set in the node, in pixels or normalized coordinates."
|
|
14
|
+
---
|
|
15
|
+
|
|
1
16
|
# Mosaic Node
|
|
2
17
|
|
|
3
18
|
## Purpose & Use Cases
|
|
4
19
|
|
|
5
|
-
The `mosaic` node
|
|
20
|
+
The `mosaic` node places the images of an array on a canvas of a fixed size, each at a position set in the node, in pixels or normalized (0-1) coordinates. The images keep their own size; to scale or rotate them, use [advanced-mosaic](./advanced-mosaic.md).
|
|
6
21
|
|
|
7
22
|
**Real-World Applications:**
|
|
8
23
|
- **Custom Layouts**: Create precise image arrangements with exact positioning
|
|
@@ -16,131 +31,106 @@ The `mosaic` node provides manual positioning of multiple images on a canvas wit
|
|
|
16
31
|
## Input/Output Specification
|
|
17
32
|
|
|
18
33
|
### Inputs
|
|
19
|
-
- **Image Array**:
|
|
20
|
-
- **
|
|
21
|
-
- **Canvas
|
|
34
|
+
- **Image Array**: an array of raw image objects or encoded JPEG/PNG/WebP/BMP `Buffer`s, read from **Input from** (`msg.payload` by default). A single image is treated as an array of one.
|
|
35
|
+
- **Positions**: set in the node's **Image Positions** table, not taken from the message.
|
|
36
|
+
- **Canvas Width / Canvas Height**: a number, or read from `msg`, `flow` or `global` for each message.
|
|
22
37
|
|
|
23
38
|
### Outputs
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
## Configuration Options
|
|
29
|
-
|
|
30
|
-
### Input/Output Paths
|
|
31
|
-
- **Input From**: `msg.payload` (default), `flow.*`, `global.*`
|
|
32
|
-
- **Output To**: `msg.payload` (default), `flow.*`, `global.*`
|
|
39
|
+
One output:
|
|
40
|
+
- **Composite Image**: one image of Canvas Width × Canvas Height, written to **Output to** (`msg.payload` by default), as a raw image object or an encoded `Buffer` (JPEG/PNG/WebP)
|
|
41
|
+
- `msg.performance.rpimage.<key>`: `{ conversion, task, total }` in milliseconds
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
The canvas takes the color space of the inputs: RGBA if any image is RGBA, else BGRA, RGB, BGR and GRAY, in that order. Every image is converted to it.
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
- **Canvas Width**: Width of output canvas in pixels
|
|
38
|
-
- **Canvas Height**: Height of output canvas in pixels
|
|
39
|
-
- **Sources**: Number, `msg.*`, `flow.*`, `global.*`
|
|
45
|
+
## Configuration Options
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
| Property | Default | Meaning |
|
|
48
|
+
|----------|---------|---------|
|
|
49
|
+
| Name | empty | Label of the node; also the key of its timings in `msg.performance.rpimage` |
|
|
50
|
+
| Input from | `msg.payload` | Where the array is read (`msg`, `flow` or `global`) |
|
|
51
|
+
| Output to | `msg.payload` | Where the composite is written (`msg`, `flow` or `global`) |
|
|
52
|
+
| Output Format | Raw (fastest) | Raw (fastest), JPEG, PNG or WebP, with Quality (`90`), PNG Optimize and the WebP options as in [resize](../transform/resize.md#output-format-options) |
|
|
53
|
+
| Debug / Debug Width | off / `200` | **Show processed image** under the node in the editor |
|
|
54
|
+
| Canvas Width | `800` | Width of the canvas in pixels |
|
|
55
|
+
| Canvas Height | `600` | Height of the canvas in pixels |
|
|
56
|
+
| Background Color | `#000000` | Colour of the canvas where no image is placed (opaque, also on canvases with alpha) |
|
|
57
|
+
| Normalized Coords | off | X and Y as fractions of the canvas size (0-1); off, in pixels |
|
|
58
|
+
| Image Positions | empty; opening the editor adds one row: image 0 at 0, 0 | Table of **Array Index**, **X Position**, **Y Position**; **Add Position** and **Remove** manage the rows |
|
|
59
|
+
| Inference | off | Under **Advanced options**: **Transform inference coordinates**, with **Inf. Input** and **Inf. Output** (both `msg.inference`) |
|
|
45
60
|
|
|
46
61
|
### Positioning System
|
|
47
62
|
|
|
48
63
|
#### Coordinate System
|
|
49
|
-
- **Normalized
|
|
50
|
-
- **
|
|
64
|
+
- **Normalized Coords off**: X and Y in pixels, rounded to whole pixels
|
|
65
|
+
- **Normalized Coords on**: X and Y multiplied by the canvas width and height
|
|
51
66
|
|
|
52
|
-
####
|
|
53
|
-
- **
|
|
54
|
-
- **
|
|
55
|
-
- **
|
|
56
|
-
- **Per-Image Control**: Individual positioning for each image
|
|
67
|
+
#### Image Positions
|
|
68
|
+
- **Array Index**: which image of the input array to place (0 = first). The same image can be placed in several rows; a row whose index is outside the array is ignored without a warning
|
|
69
|
+
- **X Position / Y Position**: where the top-left corner of the image goes. The image is placed at its own size; the part that falls outside the canvas is cut off
|
|
70
|
+
- **Overlaps**: the pixels of an image replace what is below them; alpha is not blended. With up to 4 rows, later rows are drawn over earlier ones; with more than 4 rows an addon built with OpenMP places the rows in parallel, and the order of overlapping images is then not guaranteed
|
|
57
71
|
|
|
58
|
-
###
|
|
59
|
-
|
|
60
|
-
- **JPEG**: Compressed with quality control
|
|
61
|
-
- **PNG**: Lossless with transparency support
|
|
62
|
-
- **WebP**: Modern format with excellent compression
|
|
72
|
+
### Inference
|
|
73
|
+
With **Transform inference coordinates** checked, **Inf. Input** must hold an array with one entry per input image, each the inference array of that image. Every detection (with `raw_boxes`) and segmentation polygon is mapped to each place its image was put on the canvas (clipped to the canvas) and the node writes a single flat array to **Inf. Output**; other entries are copied unchanged. Bitmap masks are not transformed. The image sizes are read from the raw image objects: with encoded `Buffer` inputs the coordinates come out as `NaN`.
|
|
63
74
|
|
|
64
|
-
##
|
|
75
|
+
## Status and Errors
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
- **
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- **Coordinate Validation**: Automatic bounds checking and position validation
|
|
77
|
+
- **Success**: green dot `OK: <n> pos in <t> ms (conv <c> ms | task <k> ms)`, where n is the number of rows whose Array Index is inside the array, or `OK: empty canvas in <t> ms` when there is none. With Debug on the status reads `OK: 1 img in <t> ms (conv <c> ms | task <k> ms) | <format> (<n> pos)`, or `(empty canvas)` at the end
|
|
78
|
+
- **Failure**: `msg.error` is set, the **first** input image is written to **Output to**, a warning is logged, the status shows a red ring `Error: <first 30 characters>` and the message is still sent. An invalid array gives `Invalid image list`; a canvas size of 0 or less gives `Canvas dimensions must be positive numbers`
|
|
79
|
+
|
|
80
|
+
## Performance Notes
|
|
71
81
|
|
|
72
|
-
|
|
73
|
-
- **Coordinate Transformation**: Efficient conversion between normalized and pixel coordinates
|
|
74
|
-
- **Bounds Checking**: Automatic validation of positions within canvas boundaries
|
|
75
|
-
- **Layer Management**: Proper handling of image placement order and overlaps
|
|
82
|
+
- The canvas is composed in one call to the native OpenCV addon, on the libuv thread pool
|
|
76
83
|
|
|
77
84
|
## Real-World Examples
|
|
78
85
|
|
|
79
|
-
###
|
|
80
|
-
|
|
81
|
-
// In function node: set specific positions for dashboard elements
|
|
86
|
+
### Four-Panel Layout
|
|
87
|
+
Image Positions (pixels, canvas 800 × 600, four 400 × 300 images):
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
| Array Index | X Position | Y Position |
|
|
90
|
+
|-------------|------------|------------|
|
|
91
|
+
| 0 | 0 | 0 |
|
|
92
|
+
| 1 | 400 | 0 |
|
|
93
|
+
| 2 | 0 | 300 |
|
|
94
|
+
| 3 | 400 | 300 |
|
|
87
95
|
|
|
88
96
|
```
|
|
89
|
-
|
|
90
|
-
[Dashboard Elements] → [Function: Set Positions] → [Mosaic: 800x600 canvas] → [Dashboard]
|
|
97
|
+
[Four images] → [Array-Out] → [Mosaic: 800x600 canvas] → [Image-Out]
|
|
91
98
|
```
|
|
92
99
|
|
|
93
100
|
### Template-Based Layout
|
|
94
|
-
|
|
95
|
-
// Predefined layout template positions
|
|
101
|
+
Image Positions with **Normalized Coords** on:
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
| Array Index | X Position | Y Position |
|
|
104
|
+
|-------------|------------|------------|
|
|
105
|
+
| 0 | 0.1 | 0.1 |
|
|
106
|
+
| 1 | 0.6 | 0.1 |
|
|
107
|
+
| 2 | 0.1 | 0.6 |
|
|
100
108
|
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
[Content Images] → [Function: Apply Template] → [Mosaic: Normalized coords] → [Layout]
|
|
104
|
-
```
|
|
109
|
+
The images keep their size, so they must fit the cells of the template; resize them first if needed.
|
|
105
110
|
|
|
106
|
-
### Overlay
|
|
111
|
+
### Logo Overlay
|
|
107
112
|
```
|
|
108
113
|
[Base Image] → [Array-In: pos=0] ┐
|
|
109
|
-
[Logo
|
|
110
|
-
[Text Overlay] → [Array-In: pos=2] ┘
|
|
111
|
-
```
|
|
112
|
-
Position logos and text overlays at specific coordinates.
|
|
113
|
-
|
|
114
|
-
### Print Layout Design
|
|
115
|
-
```javascript
|
|
116
|
-
// Precise positioning for print layout
|
|
117
|
-
canvasWidth = 1200; // Print width
|
|
118
|
-
canvasHeight = 1800; // Print height
|
|
119
|
-
{ arrayIndex: 0, x: 100, y: 100 } // Header image
|
|
120
|
-
{ arrayIndex: 1, x: 100, y: 400 } // Content image
|
|
121
|
-
{ arrayIndex: 2, x: 100, y: 1200 } // Footer image
|
|
122
|
-
|
|
114
|
+
[Logo] → [Array-In: pos=1] ├→ [Array-Out] → [Mosaic: rows 0 at 0,0 and 1 at 20,20] → [Branded Image]
|
|
123
115
|
```
|
|
116
|
+
Place a logo over the top-left corner of a photo; the canvas has the size of the photo. Array-In and Array-Out are part of [`@rosepetal/node-red-contrib-utils`](https://docs.rosepetal.ai/flows/node-red-contrib-utils/nodes/io/array-in).
|
|
124
117
|
|
|
125
118
|
## Common Issues & Troubleshooting
|
|
126
119
|
|
|
127
|
-
###
|
|
128
|
-
- **Issue**:
|
|
129
|
-
- **Solution**:
|
|
130
|
-
- **Validation**: Check that positions array contains valid coordinates
|
|
120
|
+
### Images Missing from the Canvas
|
|
121
|
+
- **Issue**: An image does not appear
|
|
122
|
+
- **Solution**: Check that its **Array Index** is smaller than the length of the input array, and that its position is inside the canvas
|
|
131
123
|
|
|
132
|
-
### Coordinate System Confusion
|
|
124
|
+
### Coordinate System Confusion
|
|
133
125
|
- **Issue**: Images appearing in wrong locations
|
|
134
|
-
- **Solution**:
|
|
126
|
+
- **Solution**: Check **Normalized Coords** against your values
|
|
135
127
|
- **Normalized**: Use 0-1 values for relative positioning
|
|
136
128
|
- **Pixel**: Use absolute coordinates within canvas bounds
|
|
137
129
|
|
|
138
130
|
### Canvas Size Problems
|
|
139
|
-
- **Issue**: Images clipped
|
|
140
|
-
- **Solution**:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
- **
|
|
145
|
-
- **Result**: Images ignored with warnings logged
|
|
146
|
-
- **Solution**: Validate arrayIndex values against input array length
|
|
131
|
+
- **Issue**: Images clipped at the edges
|
|
132
|
+
- **Solution**: Make the canvas large enough for the images at their own size, or resize them first
|
|
133
|
+
|
|
134
|
+
### Dynamic Positions
|
|
135
|
+
- **Issue**: The positions must change per message
|
|
136
|
+
- **Cause**: Positions are fixed in the node configuration; only the canvas size can come from the message
|