@rosepetal/node-red-contrib-image-tools 1.7.0 → 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/.github/workflows/build-prebuild.yml +1 -1
- package/README.md +39 -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/nodes/specialized/image-align.html +11 -4
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +2 -1
- 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/src/heat-diff.cpp +4 -0
- package/rosepetal-image-engine/src/image-align.cpp +71 -3
- package/scripts/build-opencv-static.sh +6 -0
|
@@ -1,248 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Blend Node - Combine Two Images"
|
|
3
|
+
description: "Blend two images in Node-RED with an adjustable opacity, with optional alpha compositing and background color removal. Part of @rosepetal/node-red-contrib-image-tools."
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: "keywords"
|
|
7
|
+
content: "node-red, blend, opacity, alpha compositing, overlay, watermark, background removal, opencv, rosepetal"
|
|
8
|
+
- - meta
|
|
9
|
+
- property: "og:title"
|
|
10
|
+
content: "Blend Node - @rosepetal/node-red-contrib-image-tools"
|
|
11
|
+
- - meta
|
|
12
|
+
- property: "og:description"
|
|
13
|
+
content: "Blend two images in Node-RED with an adjustable opacity, with optional alpha compositing and background color removal."
|
|
14
|
+
---
|
|
15
|
+
|
|
1
16
|
# Blend Node
|
|
2
17
|
|
|
3
18
|
## Purpose & Use Cases
|
|
4
19
|
|
|
5
|
-
The `blend` node combines two images
|
|
20
|
+
The `blend` node combines two images into one. In the default mode it mixes them with a weight (a cross-fade); with **Alpha Compositing** it lays Image 2 over Image 1 using the alpha channel of Image 2, and can first make one background colour of Image 2 transparent.
|
|
6
21
|
|
|
7
22
|
**Real-World Applications:**
|
|
8
|
-
- **Watermark Application**:
|
|
9
|
-
- **Background Replacement**:
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
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]*
|
|
23
|
+
- **Watermark Application**: Lay a semi-transparent logo (with alpha) over photos
|
|
24
|
+
- **Background Replacement**: Remove a uniform background colour from a subject and lay it over a new background
|
|
25
|
+
- **Before/After Overlays**: Cross-fade an image with its processed version
|
|
26
|
+
- **Visual Inspection**: Overlay a heat map or mask image on the original
|
|
15
27
|
|
|
16
28
|
## Input/Output Specification
|
|
17
29
|
|
|
18
30
|
### Inputs
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
-
|
|
31
|
+
- **Image 1**: the base image, read from `msg.payload.image1` by default
|
|
32
|
+
- **Image 2**: the overlay image, read from `msg.payload.image2` by default
|
|
33
|
+
- Each is a raw image object or an encoded JPEG/PNG/WebP/BMP `Buffer`. Only `msg` properties are read: the editor also offers `flow` and `global`, but the node reads the typed text as a `msg` path.
|
|
22
34
|
|
|
23
35
|
### Outputs
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
36
|
+
One output:
|
|
37
|
+
- **Blended Image**: written to the `msg` property **Output** (`msg.payload` by default) as a raw image object or an encoded `Buffer` (JPEG/PNG/WebP)
|
|
38
|
+
- **Dimensions**: when the images differ in size, both are scaled (without keeping the aspect ratio) to the largest width and the largest height of the two
|
|
39
|
+
- `msg.performance.rpimage.<key>`: `{ conversion, task, total }` in milliseconds
|
|
27
40
|
|
|
28
41
|
## Configuration Options
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
| Property | Default | Meaning |
|
|
44
|
+
|----------|---------|---------|
|
|
45
|
+
| Image 1 | `msg.payload.image1` | Base image |
|
|
46
|
+
| Image 2 | `msg.payload.image2` | Overlay image |
|
|
47
|
+
| Output | `msg.payload` | Where the result is written |
|
|
48
|
+
| 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) |
|
|
49
|
+
| Debug / Debug Width | off / `200` | **Show processed image** under the node in the editor |
|
|
50
|
+
| Alpha Compositing | off | **Use Image 1 as base layer**: lay Image 2 over Image 1 with its alpha channel |
|
|
51
|
+
| Background Removal | off | *Alpha Compositing only.* **Remove background from overlay image** |
|
|
52
|
+
| Background Color | `#ffffff` | *Background Removal only.* The colour made transparent in Image 2 |
|
|
53
|
+
| Color Tolerance | `10` | *Background Removal only.* 0-100 %: how far a pixel's colour may be from Background Color to be removed |
|
|
54
|
+
| Opacity | `50` | 0-100 %: see below |
|
|
34
55
|
|
|
35
|
-
|
|
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
|
|
56
|
+
The editor has no Name field for this node, so its timings are recorded under `msg.performance.rpimage.rp_blend`.
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
An **Opacity** or **Color Tolerance** of 0 is read as the default (50 and 10): use 1 for the lowest value.
|
|
41
59
|
|
|
42
|
-
|
|
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%)
|
|
60
|
+
### Blending Modes
|
|
46
61
|
|
|
47
|
-
####
|
|
62
|
+
#### Weighted Blend (Alpha Compositing off)
|
|
63
|
+
- **Result**: Image 1 × Opacity + Image 2 × (100 − Opacity). At 100 only Image 1 is visible; at 50 both count the same
|
|
64
|
+
- **Color space**: both images are converted to the one with the most channels (RGBA, then BGRA, RGB, BGR and GRAY)
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
- **
|
|
51
|
-
- **
|
|
52
|
-
- **Use Case**: Professional compositing with transparent overlays
|
|
66
|
+
#### Alpha Compositing
|
|
67
|
+
- **Result**: Image 2 over Image 1 ("over" operator), with the alpha of Image 2 multiplied by Opacity. At 100 the overlay is fully applied; low values make it fainter
|
|
68
|
+
- **Output**: always 4 channels (`BGRA`). Images without alpha count as opaque, so an RGB overlay at Opacity 100 covers the base completely
|
|
53
69
|
|
|
54
|
-
|
|
55
|
-
- **
|
|
56
|
-
- **Background Color
|
|
57
|
-
- **Color Tolerance**: How closely colors must match for removal (0-100%)
|
|
58
|
-
- **Use Case**: Green screen compositing, product photography
|
|
70
|
+
#### Background Removal
|
|
71
|
+
- **Operation**: pixels of Image 2 whose hue, saturation and value are all within Color Tolerance of Background Color become transparent, with a slight blur of the mask edge (above 1 % tolerance). The existing alpha channel of Image 2 is replaced
|
|
72
|
+
- **Note**: the current version swaps the red and blue components of Background Color before matching. White, black, grays, pure green and magenta are matched as expected; for other colours, enter the colour with red and blue exchanged
|
|
59
73
|
|
|
60
74
|
### Output Format Options
|
|
61
|
-
- **Raw**: Standard image object (fastest
|
|
62
|
-
- **JPEG**: Compressed
|
|
63
|
-
- **PNG**:
|
|
64
|
-
- **WebP**:
|
|
75
|
+
- **Raw**: Standard image object (fastest between image nodes)
|
|
76
|
+
- **JPEG**: Compressed; the alpha channel is dropped
|
|
77
|
+
- **PNG**: Lossless, keeps the alpha channel
|
|
78
|
+
- **WebP**: Keeps the alpha channel
|
|
65
79
|
|
|
66
|
-
##
|
|
80
|
+
## Status and Errors
|
|
81
|
+
|
|
82
|
+
- **Success**: green dot `OK: 1 img in <t> ms (conv <c> ms | task <k> ms)`, plus the preview format with Debug on
|
|
83
|
+
- **Failure**: `msg.error` is set, Image 1 is written to **Output**, a warning is logged, the status shows a red ring `Error: <first 30 characters>` and the message is still sent. Missing or invalid images give `First image is invalid or missing` or `Second image is invalid or missing`
|
|
67
84
|
|
|
68
|
-
|
|
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
|
|
85
|
+
## Performance Notes
|
|
73
86
|
|
|
74
|
-
|
|
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
|
|
87
|
+
- Conversion, scaling, background removal and blending run in one call to the native OpenCV addon, on the libuv thread pool
|
|
78
88
|
|
|
79
89
|
## Real-World Examples
|
|
80
90
|
|
|
81
91
|
### Watermark Application
|
|
82
92
|
```
|
|
83
|
-
[
|
|
84
|
-
[Logo] → [Set as image2] ├→ [Blend: 20% opacity] → [Watermarked Photo]
|
|
93
|
+
[Function: msg.payload = { image1: photo, image2: logo }] → [Blend: Alpha Compositing, Opacity 30] → [Watermarked Photo]
|
|
85
94
|
```
|
|
86
|
-
|
|
95
|
+
The logo is scaled to the size of the photo, so it should already be a full-size transparent layer with the logo where it must appear.
|
|
87
96
|
|
|
88
97
|
### Background Replacement
|
|
89
98
|
```
|
|
90
|
-
[
|
|
91
|
-
[
|
|
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
|
+
[New Background] → image1 ┐
|
|
100
|
+
[Subject on white] → image2 ├→ [Blend: Alpha Compositing, Background Removal #ffffff, Tolerance 15, Opacity 100] → [Composite]
|
|
99
101
|
```
|
|
100
|
-
|
|
102
|
+
Make the white background of the subject transparent and lay it over the new background.
|
|
101
103
|
|
|
102
|
-
###
|
|
104
|
+
### Cross-Fade
|
|
103
105
|
```
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
+
[Original] → image1 ┐
|
|
107
|
+
[Filtered] → image2 ├→ [Blend: Opacity 70] → [70 % original, 30 % filtered]
|
|
106
108
|
```
|
|
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
109
|
|
|
116
110
|
## Common Issues & Troubleshooting
|
|
117
111
|
|
|
118
|
-
###
|
|
119
|
-
- **Issue**:
|
|
120
|
-
- **
|
|
121
|
-
- **
|
|
112
|
+
### The Overlay Covers the Base Completely
|
|
113
|
+
- **Issue**: With Alpha Compositing only Image 2 is visible
|
|
114
|
+
- **Cause**: Image 2 has no alpha channel (or it is fully opaque) and Opacity is 100
|
|
115
|
+
- **Solution**: Lower Opacity, use an overlay with alpha, or turn on Background Removal
|
|
122
116
|
|
|
123
|
-
### Transparency
|
|
124
|
-
- **Issue**: Transparent areas become
|
|
125
|
-
- **Solution**:
|
|
126
|
-
- **Requirement**: Overlay image must have actual alpha channel data
|
|
117
|
+
### Transparency Lost
|
|
118
|
+
- **Issue**: Transparent areas become black or white
|
|
119
|
+
- **Solution**: Use PNG or WebP output; JPEG drops the alpha channel
|
|
127
120
|
|
|
128
121
|
### Background Removal Artifacts
|
|
129
122
|
- **Issue**: Incomplete or over-aggressive background removal
|
|
130
|
-
- **Solution**: Adjust
|
|
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
|
-
```
|
|
123
|
+
- **Solution**: Adjust Color Tolerance; check the note on red and blue above for coloured backgrounds
|
|
200
124
|
|
|
201
|
-
###
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
```
|
|
125
|
+
### Stretched Images
|
|
126
|
+
- **Issue**: One image is distorted
|
|
127
|
+
- **Cause**: Images of different sizes are both scaled to the largest width and height
|
|
128
|
+
- **Solution**: Resize or pad the images to the same size first
|
|
214
129
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
|
130
|
+
### Images from Context Are Ignored
|
|
131
|
+
- **Issue**: Image 1 or Image 2 set to `flow` or `global` is not found
|
|
132
|
+
- **Solution**: Copy the image into the message first (Change node); this node reads `msg` properties only
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Folder-In Node - Emit the Images of a Folder"
|
|
3
|
+
description: "Emit the image files of a folder one by one at a fixed interval in Node-RED, in a loop or once, started and stopped with the node's button. Part of @rosepetal/node-red-contrib-image-tools."
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: "keywords"
|
|
7
|
+
content: "node-red, folder-in, image folder, image sequence, replay images, interval, loop, rosepetal"
|
|
8
|
+
- - meta
|
|
9
|
+
- property: "og:title"
|
|
10
|
+
content: "Folder-In Node - @rosepetal/node-red-contrib-image-tools"
|
|
11
|
+
- - meta
|
|
12
|
+
- property: "og:description"
|
|
13
|
+
content: "Emit the image files of a folder one by one at a fixed interval in Node-RED, in a loop or once, started and stopped with the node's button."
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Folder-In Node
|
|
17
|
+
|
|
18
|
+
> **Type**: `rp-folder-in` · **Category**: I/O · **Since**: v1.1.3
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
Folder-In reads the image files of a folder and sends them one per message at a fixed interval, as the same raw image object that [Image-In](./image-in.md) produces. It has no input: the button on the node starts and stops it. Unlike Image-In, which loads one file per incoming message, it replays a whole folder on its own.
|
|
23
|
+
|
|
24
|
+
**Use cases**
|
|
25
|
+
- Replay a set of saved camera images through an inspection flow, as if a camera were sending them
|
|
26
|
+
- Test a flow with a fixed set of images at a controlled rate
|
|
27
|
+
- Run a folder of images once through a model and save the results
|
|
28
|
+
|
|
29
|
+
## Inputs
|
|
30
|
+
|
|
31
|
+
None. Press the button on the left of the node to start; press it again to stop. The button is disabled while the node has changes that are not deployed.
|
|
32
|
+
|
|
33
|
+
On each start the node lists the folder again, keeps the files whose extension is `.jpg`, `.jpeg`, `.png`, `.webp`, `.bmp`, `.gif` or `.tiff` (in any letter case), and sorts them by name. Subfolders are not read. Files added while it runs are picked up at the next start.
|
|
34
|
+
|
|
35
|
+
## Outputs
|
|
36
|
+
|
|
37
|
+
One output. Every interval the node sends a **new** message with:
|
|
38
|
+
|
|
39
|
+
- **Output to** (`msg.payload` by default): the image, `{ data, width, height, channels, colorSpace, dtype }`, with `colorSpace` `GRAY`, `RGB` or `RGBA` from the channel count and `dtype` `uint8`. BMP files are decoded by the native OpenCV addon, the other formats by `sharp`. When **Output to** is a `flow` or `global` key, the image is stored there and the message carries only the properties below.
|
|
40
|
+
- `msg._folderIn`: `{ fileName, filePath, index, total }`, where `index` is the position of the file in the sorted list (from 0) and `total` the number of files. With Debug on, it also has `debug`, the format of the preview.
|
|
41
|
+
- `msg.performance.rpimage.<key>`: `{ conversion, task, total }` in milliseconds, where `conversion` is the decoding time. `<key>` is the name of the node, or `rp_folder_in` when it has no name.
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
| Field | Type | Default | Description |
|
|
46
|
+
|---|---|---|---|
|
|
47
|
+
| Name | string | empty | Label of the node in the editor |
|
|
48
|
+
| Folder Path | string | empty (required) | Folder to read. Only a fixed string works: with `msg`, `flow` or `global` the node warns `Dynamic folder paths require message input to resolve` and does not start |
|
|
49
|
+
| Interval (ms) | number | `1000` | Time between two images. The first image is sent at once. If loading an image takes longer than the interval, the next one follows as soon as it is done. An empty or negative value gives 1000. Only a number works: a `msg`, `flow` or `global` value is not resolved and gives 1000 |
|
|
50
|
+
| Mode | enum | Loop (repeat images) | **Loop (repeat images)**: start again with the first file after the last one. **One-shot (stop at end)**: stop after the last file |
|
|
51
|
+
| Output to | TypedInput (msg/flow/global) | `msg.payload` | Where the image is written |
|
|
52
|
+
| Debug | boolean | off | **Show loaded images**: a preview of each image under the node in the editor |
|
|
53
|
+
| Debug Width | number | `200` | Width of the preview in pixels |
|
|
54
|
+
|
|
55
|
+
## Status
|
|
56
|
+
|
|
57
|
+
| Status | Meaning |
|
|
58
|
+
|---|---|
|
|
59
|
+
| Grey ring `Stopped` | Not running (after deploy, or after the button stopped it) |
|
|
60
|
+
| Yellow dot `Scanning folder...` | Listing the folder |
|
|
61
|
+
| Red ring `No images found` | The folder has no file with a supported extension, cannot be read, or Folder Path is empty or dynamic |
|
|
62
|
+
| Green dot `Started (<n> images, <ms>ms)` | Running |
|
|
63
|
+
| Blue dot `Loading <file>...` | Reading and decoding a file |
|
|
64
|
+
| Green dot `<i>/<n>: <file>` | Sent image number `<i>` of `<n>`; with Debug on, the preview format follows |
|
|
65
|
+
| Grey ring `Completed all images` | One-shot mode reached the end |
|
|
66
|
+
| Red ring `Error: <message>` | A file could not be loaded |
|
|
67
|
+
|
|
68
|
+
## Examples
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
[folder-in: /data/samples, 500 ms, Loop] → [rp-resize] → [inference] → [debug]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Feeds the saved samples to a model at two images per second, over and over, until the button stops the node.
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
[folder-in: /data/batch, 100 ms, One-shot] → [rp-color-convert: GRAY] → [rp-image-out]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Converts every image of the folder once, ten per second, and saves the results.
|
|
81
|
+
|
|
82
|
+
## Troubleshooting
|
|
83
|
+
|
|
84
|
+
- **The node does not start and shows `No images found`** — Cause: Folder Path is empty, is set from `msg` / `flow` / `global`, does not exist (`Error scanning folder: ...` in the debug sidebar), or holds no file with a supported extension (`.tif` is not one). · Solution: set Folder Path as a string to an existing folder that the Node-RED process can read.
|
|
85
|
+
- **The interval does not change when set from `msg`, `flow` or `global`** — Cause: those values are not resolved. · Solution: type the interval as a number.
|
|
86
|
+
- **`Error: ...` repeats for the same file** — Cause: a file with a supported extension cannot be decoded (a corrupt file, or a grayscale image with alpha: `Unsupported number of channels: 2`). The node does not move past the failing file. · Solution: stop the node, remove or convert the file, and start it again.
|
|
87
|
+
- **Pressing the button shows `Node not deployed`** — Cause: the runtime has no running node with this id (the toggle request got a 404). A new or changed node cannot get there: its button stays disabled until it is deployed. · Solution: deploy the flow, with the node and its flow enabled.
|
|
88
|
+
|
|
89
|
+
## See Also
|
|
90
|
+
|
|
91
|
+
- [image-in](./image-in.md): load one file per message, with the path taken from the message if needed
|
|
92
|
+
- [image-out](./image-out.md): save images to disk
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Image-In Node - Load Image Files"
|
|
3
|
+
description: "Load an image file from disk into the raw image object used by the other image nodes, with a fixed or a dynamic file path. Part of @rosepetal/node-red-contrib-image-tools."
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: "keywords"
|
|
7
|
+
content: "node-red, image-in, load image, read image file, jpeg, png, webp, bmp, sharp, rosepetal"
|
|
8
|
+
- - meta
|
|
9
|
+
- property: "og:title"
|
|
10
|
+
content: "Image-In Node - @rosepetal/node-red-contrib-image-tools"
|
|
11
|
+
- - meta
|
|
12
|
+
- property: "og:description"
|
|
13
|
+
content: "Load an image file from disk into the raw image object used by the other image nodes, with a fixed or a dynamic file path."
|
|
14
|
+
---
|
|
15
|
+
|
|
1
16
|
# Image-In Node
|
|
2
17
|
|
|
3
18
|
## Purpose & Use Cases
|
|
@@ -15,61 +30,61 @@ The `image-in` node is the primary entry point for loading images from the files
|
|
|
15
30
|
## Input/Output Specification
|
|
16
31
|
|
|
17
32
|
### Inputs
|
|
18
|
-
-
|
|
33
|
+
- Any message triggers the node. Its content is only used when **File Path** or **Debug Width** is read from a `msg` property.
|
|
19
34
|
|
|
20
35
|
### Outputs
|
|
21
|
-
The node
|
|
36
|
+
One output. The node writes the decoded image to **Output to** (`msg.payload` by default) and sends the message:
|
|
22
37
|
|
|
23
38
|
```javascript
|
|
24
39
|
{
|
|
25
|
-
data: Buffer, // Raw pixel data
|
|
40
|
+
data: Buffer, // Raw pixel data, row by row
|
|
26
41
|
width: number, // Image width in pixels
|
|
27
42
|
height: number, // Image height in pixels
|
|
28
|
-
channels: number, //
|
|
29
|
-
colorSpace: string, // "GRAY", "RGB"
|
|
30
|
-
dtype:
|
|
43
|
+
channels: number, // 1, 3 or 4
|
|
44
|
+
colorSpace: string, // "GRAY", "RGB" or "RGBA", from the channel count
|
|
45
|
+
dtype: "uint8"
|
|
31
46
|
}
|
|
32
47
|
```
|
|
33
48
|
|
|
49
|
+
When **Output to** is a `flow` or `global` key, the image is stored there and the message is sent unchanged.
|
|
50
|
+
|
|
34
51
|
## Configuration Options
|
|
35
52
|
|
|
53
|
+
| Property | Default | Meaning |
|
|
54
|
+
|----------|---------|---------|
|
|
55
|
+
| Name | empty | Label of the node in the editor |
|
|
56
|
+
| File Path | empty (required) | Path of the image file on the Node-RED host: a fixed string, or read from `msg`, `flow` or `global` |
|
|
57
|
+
| Output to | `msg.payload` | Where the image object is written: a `msg` property or a `flow` / `global` key |
|
|
58
|
+
| Debug | off | **Show loaded image**: shows a preview of the image under the node in the editor |
|
|
59
|
+
| Debug Width | `200` | Width of the preview in pixels: a number, or read from `msg`, `flow` or `global` |
|
|
60
|
+
|
|
36
61
|
### File Path
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **String**: Static absolute or relative path (e.g., `/home/user/photos/image.jpg`)
|
|
41
|
-
- **msg.***: Dynamic path from message properties (e.g., `msg.imagePath`)
|
|
42
|
-
- **flow.***: Dynamic path from flow context (e.g., `flow.currentImageFile`)
|
|
43
|
-
- **global.***: Dynamic path from global context (e.g., `global.basePath`)
|
|
44
|
-
- **Supported Formats**: All formats supported by Sharp (JPEG, PNG, WebP, ...)
|
|
45
|
-
|
|
46
|
-
### Output Location
|
|
47
|
-
- **Default**: `msg.payload`
|
|
48
|
-
- **Options**:
|
|
49
|
-
- `msg.*` - Store in message property
|
|
50
|
-
- `flow.*` - Store in flow context
|
|
51
|
-
- `global.*` - Store in global context
|
|
52
|
-
- **Use Case**: Choose based on how you want to access the image downstream
|
|
62
|
+
- **Fixed path**: an absolute path, or a path relative to the working directory of the Node-RED process (e.g., `/home/user/photos/image.jpg`)
|
|
63
|
+
- **Dynamic path**: for example `msg.imagePath` or `flow.currentImageFile`
|
|
64
|
+
- **Formats**: BMP files are decoded by the native OpenCV addon; every other file is decoded by `sharp` (JPEG, PNG, WebP, TIFF, GIF and the other formats it reads). Images with 2 channels (grayscale with alpha) are rejected
|
|
53
65
|
|
|
54
66
|
### Debug Options
|
|
55
|
-
- **Show
|
|
56
|
-
-
|
|
57
|
-
- **Dynamic Width**: Can be resolved from msg, flow, or global context
|
|
58
|
-
- **Interactive**: Preview appears in Node-RED editor with timing information
|
|
67
|
+
- **Show loaded image**: the preview is a JPEG of the loaded image scaled to **Debug Width**, sent to the editor and drawn under the node
|
|
68
|
+
- The status text gets ` | jpg debug` appended
|
|
59
69
|
|
|
60
70
|
## Performance Notes
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
- **Async Processing**: Non-blocking operation with performance timing display
|
|
65
|
-
- **Memory Efficient**: Optimized for large images and batch processing
|
|
66
|
-
- **Metadata Extraction**: Complete image properties extracted during load
|
|
72
|
+
- The file is read with asynchronous file I/O and decoded by `sharp` or by the native addon, off the Node-RED event loop.
|
|
73
|
+
- The node does not record timings in `msg.performance`.
|
|
67
74
|
|
|
68
75
|
### Status Display
|
|
69
|
-
|
|
70
|
-
- **
|
|
71
|
-
- **
|
|
72
|
-
|
|
76
|
+
- **Blue dot** `reading...`: the file is being read
|
|
77
|
+
- **Green dot** `<width>x<height> to <type>.<path>` (for example `1920x1080 to msg.payload`): the image was loaded
|
|
78
|
+
- **Red ring** `Error`: the file could not be decoded
|
|
79
|
+
|
|
80
|
+
### Errors
|
|
81
|
+
On every failure the node logs a warning and sends **no** message:
|
|
82
|
+
|
|
83
|
+
| Warning | Cause |
|
|
84
|
+
|---------|-------|
|
|
85
|
+
| `File path is not configured or resolved.` | **File Path** is empty, or the `msg` / `flow` / `global` value it points to is empty |
|
|
86
|
+
| `Cannot access file: <path>` | The file does not exist or Node-RED cannot read it. The status stays at `reading...` |
|
|
87
|
+
| `Error reading image file: <message>` | The file is not an image `sharp` or OpenCV can decode, or it has an unsupported channel count |
|
|
73
88
|
|
|
74
89
|
## Real-World Examples
|
|
75
90
|
|
|
@@ -101,31 +116,25 @@ Enable debug preview to visually verify image loading and dimensions.
|
|
|
101
116
|
```
|
|
102
117
|
[Image-In] → [Array-In] → [Array-Out] → [Batch Transform]
|
|
103
118
|
```
|
|
104
|
-
Collect multiple images into
|
|
119
|
+
Collect multiple images into an array for the nodes that process arrays. 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).
|
|
105
120
|
|
|
106
121
|
## Common Issues & Troubleshooting
|
|
107
122
|
|
|
108
123
|
### File Access Problems
|
|
109
|
-
- **Issue**:
|
|
110
|
-
- **Solution**: Verify file
|
|
111
|
-
- **Check**: Use absolute paths
|
|
124
|
+
- **Issue**: `Cannot access file` warning and no message
|
|
125
|
+
- **Solution**: Verify that the file exists on the Node-RED host and that the Node-RED process can read it
|
|
126
|
+
- **Check**: Use absolute paths; relative paths are resolved from the working directory of Node-RED, not from the user directory
|
|
112
127
|
|
|
113
128
|
### Unsupported Format
|
|
114
|
-
- **Issue**:
|
|
115
|
-
- **Solution**:
|
|
116
|
-
- **Check**: Verify file
|
|
117
|
-
|
|
118
|
-
### Memory Issues
|
|
119
|
-
- **Issue**: Large images cause performance problems
|
|
120
|
-
- **Solution**: Process images in batches, consider resizing after load
|
|
121
|
-
- **Optimization**: Use flow/global context for sharing large images
|
|
129
|
+
- **Issue**: `Error reading image file: ...` warning and a red `Error` status
|
|
130
|
+
- **Solution**: Use a format `sharp` reads (JPEG, PNG, WebP, TIFF, GIF) or BMP; convert grayscale images with alpha to RGBA or GRAY first
|
|
131
|
+
- **Check**: Verify the file is not corrupted using an image viewer
|
|
122
132
|
|
|
123
133
|
### Path Configuration
|
|
124
|
-
- **Static Path**: Set File Path to string type for fixed file
|
|
125
|
-
- **Dynamic Path**:
|
|
126
|
-
- **
|
|
134
|
+
- **Static Path**: Set File Path to the string type for a fixed file
|
|
135
|
+
- **Dynamic Path**: Read File Path from `msg`, `flow` or `global` to choose the file at runtime
|
|
136
|
+
- **Empty path**: `File path is not configured or resolved.` means the property the path is read from is missing or empty
|
|
127
137
|
|
|
128
138
|
### Debug Display Issues
|
|
129
139
|
- **Issue**: Debug preview not appearing
|
|
130
|
-
- **Solution**:
|
|
131
|
-
- **Performance**: Large debug widths may impact editor performance
|
|
140
|
+
- **Solution**: Check the Debug box, deploy, and keep the flow open in the editor
|