@rosepetal/node-red-contrib-image-tools 1.1.3
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/.gitattributes +6 -0
- package/.github/workflows/build-prebuild.yml +326 -0
- package/LICENSE +13 -0
- package/README.md +161 -0
- package/artifacts/darwin-arm64/package.json +25 -0
- package/artifacts/linux-arm64/package.json +26 -0
- package/artifacts/linux-x64/package.json +26 -0
- package/artifacts/linuxmusl-x64/package.json +26 -0
- package/assets/flow_time_example.gif +0 -0
- package/assets/nodes/io/array-in-demo.gif +0 -0
- package/assets/nodes/io/array-out-demo.gif +0 -0
- package/assets/nodes/io/array-select-demo.gif +0 -0
- package/assets/nodes/io/image-in-demo.gif +0 -0
- package/assets/nodes/mix/concat-demo.gif +0 -0
- package/assets/nodes/mix/mosaic-demo.gif +0 -0
- package/assets/nodes/transform/crop-demo.gif +0 -0
- package/assets/nodes/transform/filter-demo.gif +0 -0
- package/assets/nodes/transform/padding-demo.gif +0 -0
- package/assets/nodes/transform/resize-demo.gif +0 -0
- package/assets/nodes/transform/rotate-demo.gif +0 -0
- package/docs/nodes/blend/add-mask.md +275 -0
- package/docs/nodes/blend/add-masks.md +284 -0
- package/docs/nodes/blend/blend.md +248 -0
- package/docs/nodes/io/array-in.md +119 -0
- package/docs/nodes/io/array-out.md +150 -0
- package/docs/nodes/io/array-select.md +157 -0
- package/docs/nodes/io/image-in.md +131 -0
- package/docs/nodes/io/image-out.md +179 -0
- package/docs/nodes/io/queue.md +57 -0
- package/docs/nodes/io/save-file.md +30 -0
- package/docs/nodes/mix/advanced-mosaic.md +108 -0
- package/docs/nodes/mix/concat.md +127 -0
- package/docs/nodes/mix/mosaic.md +146 -0
- package/docs/nodes/specialized/cropBB.md +271 -0
- package/docs/nodes/specialized/image-align.md +426 -0
- package/docs/nodes/transform/crop.md +132 -0
- package/docs/nodes/transform/draw.md +77 -0
- package/docs/nodes/transform/filter.md +84 -0
- package/docs/nodes/transform/padding.md +133 -0
- package/docs/nodes/transform/resize.md +158 -0
- package/docs/nodes/transform/rotate.md +121 -0
- package/docs/nodes/util/block-detect.md +46 -0
- package/install.sh +144 -0
- package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
- package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
- package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
- package/node-red-contrib-image-tools/package.json +64 -0
- package/npm/darwin-arm64/lib/.gitkeep +1 -0
- package/npm/darwin-arm64/package.json +25 -0
- package/npm/darwin-x64/lib/.gitkeep +1 -0
- package/npm/darwin-x64/package.json +25 -0
- package/npm/linux-arm64/lib/.gitkeep +1 -0
- package/npm/linux-arm64/package.json +26 -0
- package/npm/linux-x64/lib/.gitkeep +1 -0
- package/npm/linux-x64/package.json +26 -0
- package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
- package/npm/linuxmusl-x64/package.json +26 -0
- package/npm/win32-x64/lib/.gitkeep +1 -0
- package/npm/win32-x64/package.json +25 -0
- package/package.json +74 -0
- package/rosepetal-image-engine/binding.gyp +153 -0
- package/rosepetal-image-engine/package.json +19 -0
- package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
- package/rosepetal-image-engine/src/add-mask.cpp +240 -0
- package/rosepetal-image-engine/src/add-masks.cpp +638 -0
- package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
- package/rosepetal-image-engine/src/blend.cpp +200 -0
- package/rosepetal-image-engine/src/concat.cpp +329 -0
- package/rosepetal-image-engine/src/crop.cpp +139 -0
- package/rosepetal-image-engine/src/draw.cpp +414 -0
- package/rosepetal-image-engine/src/filter.cpp +230 -0
- package/rosepetal-image-engine/src/filters/kernels.h +171 -0
- package/rosepetal-image-engine/src/image-align.cpp +551 -0
- package/rosepetal-image-engine/src/main.cpp +36 -0
- package/rosepetal-image-engine/src/mosaic.cpp +373 -0
- package/rosepetal-image-engine/src/padding.cpp +124 -0
- package/rosepetal-image-engine/src/resize.cpp +210 -0
- package/rosepetal-image-engine/src/rotate.cpp +177 -0
- package/rosepetal-image-engine/src/utils.h +563 -0
- package/rosepetal-image-engine/test-formats.js +119 -0
- package/scripts/build-opencv-static.ps1 +166 -0
- package/scripts/build-opencv-static.sh +147 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Blend Node
|
|
2
|
+
|
|
3
|
+
## Purpose & Use Cases
|
|
4
|
+
|
|
5
|
+
The `blend` node combines two images using alpha blending techniques, allowing for sophisticated image compositing with adjustable opacity and advanced blending options. It supports transparent overlays, background removal, and color-based compositing.
|
|
6
|
+
|
|
7
|
+
**Real-World Applications:**
|
|
8
|
+
- **Watermark Application**: Add semi-transparent logos or watermarks to photos
|
|
9
|
+
- **Background Replacement**: Composite subjects onto new backgrounds with proper edge blending
|
|
10
|
+
- **Artistic Effects**: Create double exposures and artistic blended compositions
|
|
11
|
+
- **Product Photography**: Combine product shots with environmental backgrounds
|
|
12
|
+
- **UI/UX Design**: Create layered interface elements with transparency effects
|
|
13
|
+
|
|
14
|
+
*[PLACEHOLDER - Add GIF showing various blending operations including opacity, transparency, and color removal]*
|
|
15
|
+
|
|
16
|
+
## Input/Output Specification
|
|
17
|
+
|
|
18
|
+
### Inputs
|
|
19
|
+
- **Base Image**: Background or primary image (usually from `msg.payload.image1`)
|
|
20
|
+
- **Overlay Image**: Foreground or secondary image (usually from `msg.payload.image2`)
|
|
21
|
+
- **Blend Parameters**: Opacity and compositing settings via configuration or message properties
|
|
22
|
+
|
|
23
|
+
### Outputs
|
|
24
|
+
- **Blended Image**: Composite result of blending both input images
|
|
25
|
+
- **Preserved Dimensions**: Output maintains base image dimensions
|
|
26
|
+
- **Format Options**: Raw image object or encoded file formats
|
|
27
|
+
|
|
28
|
+
## Configuration Options
|
|
29
|
+
|
|
30
|
+
### Input Paths
|
|
31
|
+
- **Image 1 Path**: Location of base/background image (default: `msg.payload.image1`)
|
|
32
|
+
- **Image 2 Path**: Location of overlay/foreground image (default: `msg.payload.image2`)
|
|
33
|
+
- **Path Sources**: `msg.*`, `flow.*`, `global.*`
|
|
34
|
+
|
|
35
|
+
### Output Configuration
|
|
36
|
+
- **Output Path**: Where to store blended result (default: `msg.payload`)
|
|
37
|
+
- **Output Format**: Raw, JPEG, PNG, or WebP
|
|
38
|
+
- **Quality Settings**: Compression quality for lossy formats
|
|
39
|
+
|
|
40
|
+
### Blending Parameters
|
|
41
|
+
|
|
42
|
+
#### Opacity Control
|
|
43
|
+
- **Range**: 0-100% (0 = invisible overlay, 100 = opaque overlay)
|
|
44
|
+
- **Default**: 50% for balanced blending
|
|
45
|
+
- **Use Cases**: Watermarks (10-30%), artistic effects (40-70%), overlays (80-95%)
|
|
46
|
+
|
|
47
|
+
#### Advanced Blending Options
|
|
48
|
+
|
|
49
|
+
##### Alpha Compositing
|
|
50
|
+
- **Enable/Disable**: Use alpha channel information for proper transparency handling
|
|
51
|
+
- **Benefit**: Preserves transparency in PNG images and handles edge feathering
|
|
52
|
+
- **Use Case**: Professional compositing with transparent overlays
|
|
53
|
+
|
|
54
|
+
##### Background Removal
|
|
55
|
+
- **Enable/Disable**: Remove specific background colors from overlay image
|
|
56
|
+
- **Background Color**: Color to remove (hex, RGB, or named color)
|
|
57
|
+
- **Color Tolerance**: How closely colors must match for removal (0-100%)
|
|
58
|
+
- **Use Case**: Green screen compositing, product photography
|
|
59
|
+
|
|
60
|
+
### Output Format Options
|
|
61
|
+
- **Raw**: Standard image object (fastest for processing chains)
|
|
62
|
+
- **JPEG**: Compressed (transparency flattened to white)
|
|
63
|
+
- **PNG**: Full transparency preservation
|
|
64
|
+
- **WebP**: Modern format with transparency and compression
|
|
65
|
+
|
|
66
|
+
## Performance Notes
|
|
67
|
+
|
|
68
|
+
### C++ Backend Processing
|
|
69
|
+
- **Optimized Alpha Blending**: Hardware-accelerated blending algorithms
|
|
70
|
+
- **Color Space Handling**: Proper color space management for accurate blending
|
|
71
|
+
- **Memory Efficient**: In-place blending operations where possible
|
|
72
|
+
- **Edge Handling**: High-quality edge processing for smooth compositing
|
|
73
|
+
|
|
74
|
+
### Image Requirements
|
|
75
|
+
- **Dimension Handling**: Overlay automatically scaled/positioned to match base image
|
|
76
|
+
- **Color Space**: Both images converted to compatible color spaces for blending
|
|
77
|
+
- **Alpha Channel**: Proper alpha channel handling for transparency effects
|
|
78
|
+
|
|
79
|
+
## Real-World Examples
|
|
80
|
+
|
|
81
|
+
### Watermark Application
|
|
82
|
+
```
|
|
83
|
+
[Photo] → [Set as image1] ┐
|
|
84
|
+
[Logo] → [Set as image2] ├→ [Blend: 20% opacity] → [Watermarked Photo]
|
|
85
|
+
```
|
|
86
|
+
Add semi-transparent watermarks to protect image copyrights.
|
|
87
|
+
|
|
88
|
+
### Background Replacement
|
|
89
|
+
```
|
|
90
|
+
[Subject Photo] → [Set as image2] ┐
|
|
91
|
+
[New Background] → [Set as image1] ├→ [Blend: Background removal, Green] → [Composite]
|
|
92
|
+
```
|
|
93
|
+
Replace green screen backgrounds with new environments.
|
|
94
|
+
|
|
95
|
+
### Artistic Double Exposure
|
|
96
|
+
```
|
|
97
|
+
[Portrait] → [Set as image1] ┐
|
|
98
|
+
[Texture] → [Set as image2] ├→ [Blend: 60% opacity, Alpha compositing] → [Artistic Effect]
|
|
99
|
+
```
|
|
100
|
+
Create artistic double exposure effects.
|
|
101
|
+
|
|
102
|
+
### Product Lifestyle Shots
|
|
103
|
+
```
|
|
104
|
+
[Product Photo] → [Set as image2] ┐
|
|
105
|
+
[Lifestyle Scene] → [Set as image1] ├→ [Blend: 85% opacity, Alpha] → [Lifestyle Product Shot]
|
|
106
|
+
```
|
|
107
|
+
Composite products into lifestyle environments.
|
|
108
|
+
|
|
109
|
+
### UI Element Creation
|
|
110
|
+
```
|
|
111
|
+
[Background] → [Set as image1] ┐
|
|
112
|
+
[UI Overlay] → [Set as image2] ├→ [Blend: 90% opacity, Alpha] → [UI Component]
|
|
113
|
+
```
|
|
114
|
+
Create layered interface elements with proper transparency.
|
|
115
|
+
|
|
116
|
+
## Common Issues & Troubleshooting
|
|
117
|
+
|
|
118
|
+
### Color Matching Problems
|
|
119
|
+
- **Issue**: Colors don't blend as expected
|
|
120
|
+
- **Solution**: Ensure both images use compatible color spaces
|
|
121
|
+
- **Check**: Verify image formats and color profiles
|
|
122
|
+
|
|
123
|
+
### Transparency Issues
|
|
124
|
+
- **Issue**: Transparent areas become white or black
|
|
125
|
+
- **Solution**: Enable alpha compositing and use PNG output format
|
|
126
|
+
- **Requirement**: Overlay image must have actual alpha channel data
|
|
127
|
+
|
|
128
|
+
### Background Removal Artifacts
|
|
129
|
+
- **Issue**: Incomplete or over-aggressive background removal
|
|
130
|
+
- **Solution**: Adjust color tolerance settings and background color specification
|
|
131
|
+
- **Optimization**: Use high-quality source images with clean backgrounds
|
|
132
|
+
|
|
133
|
+
### Dimension Mismatches
|
|
134
|
+
- **Issue**: Overlay doesn't align properly with base image
|
|
135
|
+
- **Behavior**: Overlay automatically scaled to match base image dimensions
|
|
136
|
+
- **Control**: Pre-resize images if specific positioning needed
|
|
137
|
+
|
|
138
|
+
### Performance with Large Images
|
|
139
|
+
- **Issue**: Slow blending with high-resolution images
|
|
140
|
+
- **Optimization**: Resize images to appropriate output size before blending
|
|
141
|
+
- **Memory**: Monitor memory usage with very large images
|
|
142
|
+
|
|
143
|
+
## Integration Patterns
|
|
144
|
+
|
|
145
|
+
### Watermarking Workflow
|
|
146
|
+
```
|
|
147
|
+
Content Image → Resize → Position Watermark → Blend → Protected Image
|
|
148
|
+
```
|
|
149
|
+
Standard content protection workflow.
|
|
150
|
+
|
|
151
|
+
### Compositing Pipeline
|
|
152
|
+
```
|
|
153
|
+
Background → Color Correction → Subject → Background Removal → Blend → Final Composite
|
|
154
|
+
```
|
|
155
|
+
Professional compositing workflow.
|
|
156
|
+
|
|
157
|
+
### Batch Watermarking
|
|
158
|
+
```
|
|
159
|
+
Image Array → Individual Blending → Watermark Application → Protected Collection
|
|
160
|
+
```
|
|
161
|
+
Process multiple images with consistent watermarking.
|
|
162
|
+
|
|
163
|
+
### Multi-Layer Composition
|
|
164
|
+
```
|
|
165
|
+
Base → Blend with Layer 1 → Blend with Layer 2 → Blend with Layer 3 → Final Result
|
|
166
|
+
```
|
|
167
|
+
Build complex compositions with multiple layers.
|
|
168
|
+
|
|
169
|
+
## Advanced Usage
|
|
170
|
+
|
|
171
|
+
### Dynamic Opacity Based on Content
|
|
172
|
+
```javascript
|
|
173
|
+
// In function node before blend:
|
|
174
|
+
if (msg.imageType === 'portrait') {
|
|
175
|
+
msg.blendOpacity = 25; // Subtle watermark for portraits
|
|
176
|
+
} else if (msg.imageType === 'landscape') {
|
|
177
|
+
msg.blendOpacity = 40; // More visible for landscapes
|
|
178
|
+
} else {
|
|
179
|
+
msg.blendOpacity = 30; // Default opacity
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Smart Background Color Detection
|
|
184
|
+
```javascript
|
|
185
|
+
// Detect and set background removal color
|
|
186
|
+
const dominantColor = msg.backgroundAnalysis.dominantColor;
|
|
187
|
+
msg.backgroundRemovalColor = dominantColor;
|
|
188
|
+
msg.colorTolerance = 15; // Adjust based on background uniformity
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Conditional Alpha Compositing
|
|
192
|
+
```javascript
|
|
193
|
+
// Enable alpha compositing only when overlay has transparency
|
|
194
|
+
if (msg.overlay.channels === 4) { // RGBA
|
|
195
|
+
msg.useAlphaCompositing = true;
|
|
196
|
+
} else {
|
|
197
|
+
msg.useAlphaCompositing = false;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Quality-Based Blending
|
|
202
|
+
```javascript
|
|
203
|
+
// Adjust blend settings based on image quality requirements
|
|
204
|
+
if (msg.outputUse === 'print') {
|
|
205
|
+
msg.outputFormat = 'png';
|
|
206
|
+
msg.useAlphaCompositing = true;
|
|
207
|
+
} else if (msg.outputUse === 'web') {
|
|
208
|
+
msg.outputFormat = 'webp';
|
|
209
|
+
msg.outputQuality = 85;
|
|
210
|
+
} else {
|
|
211
|
+
msg.outputFormat = 'raw'; // For further processing
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Best Practices
|
|
216
|
+
|
|
217
|
+
### Image Preparation
|
|
218
|
+
- Ensure both images are high quality for best blending results
|
|
219
|
+
- Use images with compatible aspect ratios when possible
|
|
220
|
+
- Pre-process images (color correction, sizing) before blending
|
|
221
|
+
|
|
222
|
+
### Opacity Selection
|
|
223
|
+
- **Watermarks**: 10-30% for subtle protection without distraction
|
|
224
|
+
- **Artistic Effects**: 40-70% for creative double exposures
|
|
225
|
+
- **Overlays**: 80-95% for prominent but layered appearance
|
|
226
|
+
- **Background Replacement**: Variable based on subject transparency
|
|
227
|
+
|
|
228
|
+
### Transparency Handling
|
|
229
|
+
- Use PNG format when transparency is important
|
|
230
|
+
- Enable alpha compositing for professional results
|
|
231
|
+
- Test transparency appearance in final display context
|
|
232
|
+
|
|
233
|
+
### Background Removal
|
|
234
|
+
- Use clean, uniform backgrounds for best removal results
|
|
235
|
+
- Start with lower tolerance and increase if needed
|
|
236
|
+
- Consider edge feathering for smoother compositing
|
|
237
|
+
|
|
238
|
+
### Performance Optimization
|
|
239
|
+
- Resize images to final output dimensions before blending
|
|
240
|
+
- Use raw format for processing chains
|
|
241
|
+
- Monitor memory usage with large images
|
|
242
|
+
- Consider batch processing strategies for multiple images
|
|
243
|
+
|
|
244
|
+
### Quality Considerations
|
|
245
|
+
- Use appropriate output format for final destination
|
|
246
|
+
- Consider compression settings for web vs. print use
|
|
247
|
+
- Test blending results in intended viewing context
|
|
248
|
+
- Maintain backup of original images before processing
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Array-In Node
|
|
2
|
+
|
|
3
|
+
## Purpose & Use Cases
|
|
4
|
+
|
|
5
|
+
The `array-in` node collects data from various sources and tags it with position information for ordered array assembly. It works in partnership with the `array-out` node to create structured arrays from multiple parallel data streams.
|
|
6
|
+
|
|
7
|
+
**Real-World Applications:**
|
|
8
|
+
- **Batch Image Processing**: Collect multiple images for simultaneous processing
|
|
9
|
+
- **Data Aggregation**: Combine results from parallel processing pipelines
|
|
10
|
+
- **Multi-Source Analysis**: Merge data from different sensors or inputs
|
|
11
|
+
- **Synchronized Processing**: Ensure data maintains order through parallel workflows
|
|
12
|
+
- **Multi-Camera Systems**: Collect images from multiple cameras in correct sequence
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Input/Output Specification
|
|
17
|
+
|
|
18
|
+
### Inputs
|
|
19
|
+
- **Input Message**: Message containing data at the configured input path
|
|
20
|
+
- **Dynamic Position**: Array position can be resolved from message properties
|
|
21
|
+
|
|
22
|
+
### Outputs
|
|
23
|
+
The node adds metadata to the message and mirrors the extracted data into the payload only when reading from `msg.payload`. For other input paths, the existing payload remains untouched while the metadata provides access to the collected value:
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
{
|
|
27
|
+
...originalMessage,
|
|
28
|
+
payload: any, // Unchanged unless input is msg.payload; when mirrored matches meta.arrayData
|
|
29
|
+
meta: {
|
|
30
|
+
arrayPosition: number, // Index where this data belongs in array
|
|
31
|
+
arrayData: any // The extracted data from input path
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration Options
|
|
37
|
+
|
|
38
|
+
### Input From
|
|
39
|
+
- **Default**: `msg.payload`
|
|
40
|
+
- **Options**:
|
|
41
|
+
- `msg.*` - Read from message property
|
|
42
|
+
- `flow.*` - Read from flow context
|
|
43
|
+
- `global.*` - Read from global context
|
|
44
|
+
- **Purpose**: Specifies where to extract the data to be included in the array
|
|
45
|
+
|
|
46
|
+
### Array Position
|
|
47
|
+
- **Type**: Number or dynamic reference
|
|
48
|
+
- **Options**:
|
|
49
|
+
- **Fixed Number**: Static position (0, 1, 2, ...)
|
|
50
|
+
- **msg.***: Dynamic position from message property
|
|
51
|
+
- **flow.***: Position from flow context
|
|
52
|
+
- **global.***: Position from global context
|
|
53
|
+
- **Range**: Non-negative integers (0-based indexing)
|
|
54
|
+
- **Purpose**: Determines where this data appears in the final array
|
|
55
|
+
|
|
56
|
+
## Performance Notes
|
|
57
|
+
|
|
58
|
+
### Array Assembly Strategy
|
|
59
|
+
- **Position Tagging**: Lightweight metadata addition with minimal processing overhead
|
|
60
|
+
- **Memory Efficient**: Only stores references and position information
|
|
61
|
+
- **Parallel Collection**: Multiple array-in nodes can operate simultaneously
|
|
62
|
+
- **Order Preservation**: Maintains correct data sequence regardless of processing timing
|
|
63
|
+
|
|
64
|
+
### Status Display
|
|
65
|
+
- **Processing Info**: Shows array position and data type
|
|
66
|
+
- **Validation**: Indicates successful data extraction
|
|
67
|
+
- **Error Handling**: Displays warnings for missing data or invalid positions
|
|
68
|
+
|
|
69
|
+
## Real-World Examples
|
|
70
|
+
|
|
71
|
+
### Basic Multi-Image Collection
|
|
72
|
+
```
|
|
73
|
+
[Image-In: photo1.jpg] → [Array-In: pos=0] ┐
|
|
74
|
+
[Image-In: photo2.jpg] → [Array-In: pos=1] ├→ [Array-Out] → [Resize All]
|
|
75
|
+
[Image-In: photo3.jpg] → [Array-In: pos=2] ┘
|
|
76
|
+
```
|
|
77
|
+
Collect three images into an ordered array for batch processing.
|
|
78
|
+
|
|
79
|
+
### Dynamic Position Assignment
|
|
80
|
+
```
|
|
81
|
+
[Process Data] → [Set msg.index] → [Array-In: pos=msg.index] → [Array-Out]
|
|
82
|
+
```
|
|
83
|
+
Use dynamic positioning based on processing results.
|
|
84
|
+
|
|
85
|
+
### Mixed Data Sources
|
|
86
|
+
```
|
|
87
|
+
[msg.image1] → [Array-In: pos=0] ┐
|
|
88
|
+
[flow.image2] → [Array-In: pos=1] ├→ [Array-Out] → [Concat Images]
|
|
89
|
+
[global.image3] → [Array-In: pos=2] ┘
|
|
90
|
+
```
|
|
91
|
+
Combine data from different context levels.
|
|
92
|
+
|
|
93
|
+
### Conditional Assembly
|
|
94
|
+
```
|
|
95
|
+
[Switch] → [Array-In: pos=flow.nextIndex] → [Array-Out]
|
|
96
|
+
```
|
|
97
|
+
Dynamic array building based on conditions.
|
|
98
|
+
|
|
99
|
+
## Common Issues & Troubleshooting
|
|
100
|
+
|
|
101
|
+
### Position Conflicts
|
|
102
|
+
- **Issue**: Multiple nodes using same position
|
|
103
|
+
- **Solution**: Ensure each array-in node has unique position when feeding same array-out
|
|
104
|
+
- **Best Practice**: Use sequential positions starting from 0
|
|
105
|
+
|
|
106
|
+
### Missing Data
|
|
107
|
+
- **Issue**: Input path contains no data
|
|
108
|
+
- **Result**: `meta.arrayData` set to `null`
|
|
109
|
+
- **Solution**: Verify data exists at specified input path before processing
|
|
110
|
+
|
|
111
|
+
### Dynamic Position Errors
|
|
112
|
+
- **Issue**: Position resolves to non-integer or negative value
|
|
113
|
+
- **Solution**: Validate dynamic position sources return valid array indices
|
|
114
|
+
- **Check**: Use debug node to verify position values
|
|
115
|
+
|
|
116
|
+
### Array Gaps
|
|
117
|
+
- **Issue**: Non-sequential positions create sparse arrays
|
|
118
|
+
- **Result**: Array contains undefined elements at missing positions
|
|
119
|
+
- **Solution**: Use sequential positions or handle sparse arrays in downstream nodes
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Array-Out Node
|
|
2
|
+
|
|
3
|
+
## Purpose & Use Cases
|
|
4
|
+
|
|
5
|
+
The `array-out` node serves as the collection point for multiple `array-in` nodes, assembling ordered arrays from parallel data streams. It provides timeout protection and ensures data integrity during the assembly process.
|
|
6
|
+
|
|
7
|
+
**Real-World Applications:**
|
|
8
|
+
- **Batch Image Processing**: Assemble multiple images for simultaneous operations
|
|
9
|
+
- **Multi-Camera Synchronization**: Collect frames from multiple cameras in sequence
|
|
10
|
+
- **Parallel Pipeline Merging**: Combine results from parallel processing workflows
|
|
11
|
+
- **Data Aggregation**: Merge processed data from multiple sources
|
|
12
|
+
- **Quality Control**: Collect inspection results from multiple checkpoints
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Input/Output Specification
|
|
17
|
+
|
|
18
|
+
### Inputs
|
|
19
|
+
Messages from `array-in` nodes containing:
|
|
20
|
+
```javascript
|
|
21
|
+
{
|
|
22
|
+
...originalMessage,
|
|
23
|
+
payload: any, // Fallback data source
|
|
24
|
+
meta: {
|
|
25
|
+
arrayPosition: number, // Position index (0, 1, 2, ...)
|
|
26
|
+
arrayData: any // Preferred data source (takes priority over payload)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Data Extraction Priority**: The node prefers `msg.meta.arrayData` but falls back to `msg.payload` if arrayData is undefined.
|
|
32
|
+
|
|
33
|
+
### Outputs
|
|
34
|
+
|
|
35
|
+
#### Output 1 - Complete Array (Success)
|
|
36
|
+
```javascript
|
|
37
|
+
[data0, data1, data2, ...] // Ordered array of collected data
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Output 2 - Timeout Data (Error)
|
|
41
|
+
```javascript
|
|
42
|
+
{
|
|
43
|
+
[outputPath]: [data0, null, data2, ...], // Partial array in configured location
|
|
44
|
+
meta: {
|
|
45
|
+
timeout: true, // Timeout flag
|
|
46
|
+
missingPositions: [1, 4], // Positions that didn't arrive
|
|
47
|
+
collectedPositions: [0, 2, 3], // Positions that were collected
|
|
48
|
+
expectedCount: 5, // Number expected
|
|
49
|
+
collectedCount: 3, // Number actually collected
|
|
50
|
+
elapsed: 5000 // Time elapsed in milliseconds
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration Options
|
|
56
|
+
|
|
57
|
+
### Expected Count
|
|
58
|
+
- **Type**: Number (required)
|
|
59
|
+
- **Range**: Minimum 1
|
|
60
|
+
- **Purpose**: Number of array elements required before output
|
|
61
|
+
- **Validation**: Must match the number of connected array-in nodes
|
|
62
|
+
- **Impact**: Array assembly completes when this many elements are collected
|
|
63
|
+
|
|
64
|
+
### Timeout
|
|
65
|
+
- **Type**: Number (milliseconds)
|
|
66
|
+
- **Default**: 5000ms (5 seconds)
|
|
67
|
+
- **Range**: Minimum 100ms
|
|
68
|
+
- **Purpose**: Maximum wait time for all elements after first message
|
|
69
|
+
- **Behavior**: Sends partial data to output 2 on timeout
|
|
70
|
+
|
|
71
|
+
### Output Location
|
|
72
|
+
- **Default**: `msg.payload`
|
|
73
|
+
- **Options**:
|
|
74
|
+
- `msg.*` - Store in message property
|
|
75
|
+
- `flow.*` - Store in flow context
|
|
76
|
+
- `global.*` - Store in global context
|
|
77
|
+
- **Purpose**: Where to store the assembled array
|
|
78
|
+
|
|
79
|
+
## Performance Notes
|
|
80
|
+
|
|
81
|
+
### Assembly Strategy
|
|
82
|
+
- **Efficient Collection**: Uses position-based indexing for O(1) insertion
|
|
83
|
+
- **Memory Management**: Minimal overhead during collection
|
|
84
|
+
- **Timeout Protection**: Prevents indefinite waiting for missing data
|
|
85
|
+
- **State Reset**: Automatic cleanup between collection cycles
|
|
86
|
+
|
|
87
|
+
### Status Display
|
|
88
|
+
- **Collection Progress**: Shows number of items collected vs expected
|
|
89
|
+
- **Success Timing**: Displays total assembly time on completion
|
|
90
|
+
- **Timeout Warning**: Indicates when timeout occurs with diagnostic info
|
|
91
|
+
|
|
92
|
+
## Real-World Examples
|
|
93
|
+
|
|
94
|
+
### Basic Image Array Assembly
|
|
95
|
+
```
|
|
96
|
+
[Image-In: img1.jpg] → [Array-In: pos=0] ┐
|
|
97
|
+
[Image-In: img2.jpg] → [Array-In: pos=1] ├→ [Array-Out: count=3, timeout=500] → [Resize: All Images]
|
|
98
|
+
[Image-In: img3.jpg] → [Array-In: pos=2] ┘
|
|
99
|
+
```
|
|
100
|
+
Collect three images for batch resizing.
|
|
101
|
+
|
|
102
|
+
### Multi-Camera Frame Collection
|
|
103
|
+
```
|
|
104
|
+
[Camera 1] → [Array-In: pos=0] ┐
|
|
105
|
+
[Camera 2] → [Array-In: pos=1] ├→ [Array-Out: count=4, timeout=100] → [Sync Analysis]
|
|
106
|
+
[Camera 3] → [Array-In: pos=2] │
|
|
107
|
+
[Camera 4] → [Array-In: pos=3] ┘
|
|
108
|
+
```
|
|
109
|
+
Synchronize frames from multiple cameras with tight timing.
|
|
110
|
+
|
|
111
|
+
### Parallel Processing Merge
|
|
112
|
+
```
|
|
113
|
+
→ [Process A] → [Array-In: pos=0] ┐
|
|
114
|
+
→ [Process B] → [Array-In: pos=1] ├→ [Array-Out: count=3, timeout=500] → [Combine Results]
|
|
115
|
+
→ [Process C] → [Array-In: pos=2] ┘
|
|
116
|
+
```
|
|
117
|
+
Merge results from parallel processing pipelines.
|
|
118
|
+
|
|
119
|
+
### Quality Control Assembly
|
|
120
|
+
```
|
|
121
|
+
[Inspection A] → [Array-In: pos=0] ┐
|
|
122
|
+
[Inspection B] → [Array-In: pos=1] ├→ [Array-Out: timeout=10000] → [Final Report]
|
|
123
|
+
[Inspection C] → [Array-In: pos=2] ┘
|
|
124
|
+
```
|
|
125
|
+
Collect quality control results with extended timeout.
|
|
126
|
+
|
|
127
|
+
## Common Issues & Troubleshooting
|
|
128
|
+
|
|
129
|
+
### Timeout Issues
|
|
130
|
+
- **Issue**: Frequent timeouts preventing array completion
|
|
131
|
+
- **Causes**: Slow upstream processing, network delays, missing data
|
|
132
|
+
- **Solutions**:
|
|
133
|
+
- Increase timeout value for slow processes
|
|
134
|
+
- Add debug nodes to identify bottlenecks
|
|
135
|
+
- Implement fallback logic using output 2
|
|
136
|
+
|
|
137
|
+
### Count Mismatch
|
|
138
|
+
- **Issue**: Expected count doesn't match number of array-in nodes
|
|
139
|
+
- **Result**: Perpetual waiting or premature completion
|
|
140
|
+
- **Solution**: Verify expected count equals number of connected array-in nodes
|
|
141
|
+
|
|
142
|
+
### Position Conflicts
|
|
143
|
+
- **Issue**: Multiple array-in nodes using same position
|
|
144
|
+
- **Result**: Data overwrites, array count confusion
|
|
145
|
+
- **Solution**: Ensure each array-in node has unique position
|
|
146
|
+
|
|
147
|
+
### Missing Metadata
|
|
148
|
+
- **Issue**: Messages arriving without proper meta.arrayPosition
|
|
149
|
+
- **Result**: Messages ignored, incomplete arrays
|
|
150
|
+
- **Solution**: Verify all input messages come from array-in nodes
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Array-Select Node
|
|
2
|
+
|
|
3
|
+
## Purpose & Use Cases
|
|
4
|
+
|
|
5
|
+
The `array-select` node provides powerful array element selection with Python-like slicing syntax. It extracts specific elements, ranges, or patterns from arrays, making it essential for filtering and selecting processed results.
|
|
6
|
+
|
|
7
|
+
**Real-World Applications:**
|
|
8
|
+
- **Result Filtering**: Select best results from batch processing operations
|
|
9
|
+
- **Data Sampling**: Extract samples from large datasets for analysis
|
|
10
|
+
- **Quality Control**: Pick specific items that passed validation
|
|
11
|
+
- **A/B Testing**: Select specific variants for comparison
|
|
12
|
+
- **Image Gallery Creation**: Choose specific images from collections
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Input/Output Specification
|
|
17
|
+
|
|
18
|
+
### Inputs
|
|
19
|
+
- **Array Data**: Input array from the configured path
|
|
20
|
+
- **Selection String**: Pattern specifying which elements to extract
|
|
21
|
+
|
|
22
|
+
### Outputs
|
|
23
|
+
- **Single Element**: Direct element output (unless Force Array enabled)
|
|
24
|
+
- **Multiple Elements**: Always output as array
|
|
25
|
+
- **Invalid Selection**: No message sent, warning logged
|
|
26
|
+
|
|
27
|
+
## Configuration Options
|
|
28
|
+
|
|
29
|
+
### Input From
|
|
30
|
+
- **Default**: `msg.payload`
|
|
31
|
+
- **Options**:
|
|
32
|
+
- `msg.*` - Read from message property
|
|
33
|
+
- `flow.*` - Read from flow context
|
|
34
|
+
- `global.*` - Read from global context
|
|
35
|
+
- **Validation**: Input must be an array
|
|
36
|
+
|
|
37
|
+
### Selection Pattern
|
|
38
|
+
- **Type**: String with flexible syntax
|
|
39
|
+
- **Formats**:
|
|
40
|
+
- **Single Index**: `0`, `2`, `-1`
|
|
41
|
+
- **Multiple Indices**: `1,3,5` (comma-separated)
|
|
42
|
+
- **Range**: `1:4` (slice from index 1 to 3)
|
|
43
|
+
- **Step Pattern**: `0::2` (every 2nd element)
|
|
44
|
+
- **Negative Indexing**: `-1` (last), `-2:` (last two)
|
|
45
|
+
|
|
46
|
+
### Force Array
|
|
47
|
+
- **Type**: Boolean checkbox
|
|
48
|
+
- **Default**: false
|
|
49
|
+
- **Behavior**: When enabled, single elements output as arrays
|
|
50
|
+
- **Use Case**: Ensure consistent array output format
|
|
51
|
+
|
|
52
|
+
## Performance Notes
|
|
53
|
+
|
|
54
|
+
### Selection Efficiency
|
|
55
|
+
- **Minimal Memory Copy**: Efficient element extraction without full array duplication
|
|
56
|
+
- **Index Validation**: Fast bounds checking with graceful error handling
|
|
57
|
+
- **Pattern Parsing**: Optimized pattern recognition and processing
|
|
58
|
+
- **Status Display**: Real-time selection information and processing state
|
|
59
|
+
|
|
60
|
+
### Error Handling
|
|
61
|
+
- **Input Validation**: Comprehensive array and pattern validation
|
|
62
|
+
- **Graceful Degradation**: Invalid indices skipped with warnings
|
|
63
|
+
- **Bounds Checking**: Out-of-range indices handled safely
|
|
64
|
+
|
|
65
|
+
## Selection Syntax Guide
|
|
66
|
+
|
|
67
|
+
### Basic Selection
|
|
68
|
+
```
|
|
69
|
+
Array: ["A", "B", "C", "D", "E"]
|
|
70
|
+
|
|
71
|
+
0 → "A" // First element
|
|
72
|
+
-1 → "E" // Last element
|
|
73
|
+
1,3 → ["B", "D"] // Multiple specific indices
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Range Selection
|
|
77
|
+
```
|
|
78
|
+
Array: ["A", "B", "C", "D", "E"]
|
|
79
|
+
|
|
80
|
+
1:4 → ["B", "C", "D"] // Range from 1 to 3
|
|
81
|
+
0:3 → ["A", "B", "C"] // First three elements
|
|
82
|
+
-2: → ["D", "E"] // Last two elements
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step Patterns
|
|
86
|
+
```
|
|
87
|
+
Array: ["A", "B", "C", "D", "E", "F"]
|
|
88
|
+
|
|
89
|
+
0::2 → ["A", "C", "E"] // Every 2nd starting at 0
|
|
90
|
+
1::2 → ["B", "D", "F"] // Every 2nd starting at 1
|
|
91
|
+
1:5:2 → ["B", "D"] // Range 1-4, every 2nd
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Advanced Patterns
|
|
95
|
+
```
|
|
96
|
+
Array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
97
|
+
|
|
98
|
+
::3 → [0, 3, 6, 9] // Every 3rd element
|
|
99
|
+
2:8:2 → [2, 4, 6] // Range 2-7, step 2
|
|
100
|
+
-3: → [7, 8, 9] // Last 3 elements
|
|
101
|
+
:-3 → [0, 1, 2, 3, 4, 5, 6] // All but last 3
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Real-World Examples
|
|
105
|
+
|
|
106
|
+
### Best Result Selection
|
|
107
|
+
```
|
|
108
|
+
[Batch Process] → [Array-Out] → [Array-Select: "0,2,4"] → [Top Results]
|
|
109
|
+
```
|
|
110
|
+
Select 1st, 3rd, and 5th results from batch processing.
|
|
111
|
+
|
|
112
|
+
### Quality Control Sampling
|
|
113
|
+
```
|
|
114
|
+
[Production Line] → [Array-Out] → [Array-Select: "::10"] → [Quality Check]
|
|
115
|
+
```
|
|
116
|
+
Sample every 10th item for quality inspection.
|
|
117
|
+
|
|
118
|
+
### Image Gallery Creation
|
|
119
|
+
```
|
|
120
|
+
[Image Array] → [Array-Select: "1:6"] → [Display Gallery]
|
|
121
|
+
```
|
|
122
|
+
Select images 2-6 for gallery display.
|
|
123
|
+
|
|
124
|
+
### A/B Test Splitting
|
|
125
|
+
```
|
|
126
|
+
[User Array] → [Array-Select: "0::2"] → [Group A]
|
|
127
|
+
→ [Array-Select: "1::2"] → [Group B]
|
|
128
|
+
```
|
|
129
|
+
Split users into alternating test groups.
|
|
130
|
+
|
|
131
|
+
### Last N Results
|
|
132
|
+
```
|
|
133
|
+
[Processing Queue] → [Array-Out] → [Array-Select: "-5:"] → [Recent Results]
|
|
134
|
+
```
|
|
135
|
+
Get the last 5 processed items.
|
|
136
|
+
|
|
137
|
+
## Common Issues & Troubleshooting
|
|
138
|
+
|
|
139
|
+
### Invalid Input Type
|
|
140
|
+
- **Issue**: Input is not an array
|
|
141
|
+
- **Result**: Warning logged, message not sent
|
|
142
|
+
- **Solution**: Verify input is array type, use array-out to create arrays
|
|
143
|
+
|
|
144
|
+
### Out of Bounds Indices
|
|
145
|
+
- **Issue**: Selection indices exceed array length
|
|
146
|
+
- **Result**: Invalid indices ignored, partial results returned
|
|
147
|
+
- **Example**: Array length 5, selection "1,3,7" returns elements at indices 1,3 only
|
|
148
|
+
|
|
149
|
+
### Empty Selection Results
|
|
150
|
+
- **Issue**: Selection pattern matches no elements
|
|
151
|
+
- **Result**: Empty array `[]` output
|
|
152
|
+
- **Common Cause**: Range beyond array bounds
|
|
153
|
+
|
|
154
|
+
### Syntax Errors
|
|
155
|
+
- **Issue**: Invalid selection pattern syntax
|
|
156
|
+
- **Result**: Warning logged, message not sent
|
|
157
|
+
- **Solution**: Verify pattern follows documented syntax
|