@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.
Files changed (131) hide show
  1. package/.gitattributes +6 -0
  2. package/.github/workflows/build-prebuild.yml +326 -0
  3. package/LICENSE +13 -0
  4. package/README.md +161 -0
  5. package/artifacts/darwin-arm64/package.json +25 -0
  6. package/artifacts/linux-arm64/package.json +26 -0
  7. package/artifacts/linux-x64/package.json +26 -0
  8. package/artifacts/linuxmusl-x64/package.json +26 -0
  9. package/assets/flow_time_example.gif +0 -0
  10. package/assets/nodes/io/array-in-demo.gif +0 -0
  11. package/assets/nodes/io/array-out-demo.gif +0 -0
  12. package/assets/nodes/io/array-select-demo.gif +0 -0
  13. package/assets/nodes/io/image-in-demo.gif +0 -0
  14. package/assets/nodes/mix/concat-demo.gif +0 -0
  15. package/assets/nodes/mix/mosaic-demo.gif +0 -0
  16. package/assets/nodes/transform/crop-demo.gif +0 -0
  17. package/assets/nodes/transform/filter-demo.gif +0 -0
  18. package/assets/nodes/transform/padding-demo.gif +0 -0
  19. package/assets/nodes/transform/resize-demo.gif +0 -0
  20. package/assets/nodes/transform/rotate-demo.gif +0 -0
  21. package/docs/nodes/blend/add-mask.md +275 -0
  22. package/docs/nodes/blend/add-masks.md +284 -0
  23. package/docs/nodes/blend/blend.md +248 -0
  24. package/docs/nodes/io/array-in.md +119 -0
  25. package/docs/nodes/io/array-out.md +150 -0
  26. package/docs/nodes/io/array-select.md +157 -0
  27. package/docs/nodes/io/image-in.md +131 -0
  28. package/docs/nodes/io/image-out.md +179 -0
  29. package/docs/nodes/io/queue.md +57 -0
  30. package/docs/nodes/io/save-file.md +30 -0
  31. package/docs/nodes/mix/advanced-mosaic.md +108 -0
  32. package/docs/nodes/mix/concat.md +127 -0
  33. package/docs/nodes/mix/mosaic.md +146 -0
  34. package/docs/nodes/specialized/cropBB.md +271 -0
  35. package/docs/nodes/specialized/image-align.md +426 -0
  36. package/docs/nodes/transform/crop.md +132 -0
  37. package/docs/nodes/transform/draw.md +77 -0
  38. package/docs/nodes/transform/filter.md +84 -0
  39. package/docs/nodes/transform/padding.md +133 -0
  40. package/docs/nodes/transform/resize.md +158 -0
  41. package/docs/nodes/transform/rotate.md +121 -0
  42. package/docs/nodes/util/block-detect.md +46 -0
  43. package/install.sh +144 -0
  44. package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
  45. package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
  46. package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
  47. package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
  48. package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
  49. package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
  50. package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
  51. package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
  52. package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
  53. package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
  54. package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
  55. package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
  56. package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
  57. package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
  58. package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
  59. package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
  60. package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
  61. package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
  62. package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
  63. package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
  64. package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
  65. package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
  66. package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
  67. package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
  68. package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
  69. package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
  70. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
  71. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
  72. package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
  73. package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
  74. package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
  75. package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
  76. package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
  77. package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
  78. package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
  79. package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
  80. package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
  81. package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
  82. package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
  83. package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
  84. package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
  85. package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
  86. package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
  87. package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
  88. package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
  89. package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
  90. package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
  91. package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
  92. package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
  93. package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
  94. package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
  95. package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
  96. package/node-red-contrib-image-tools/package.json +64 -0
  97. package/npm/darwin-arm64/lib/.gitkeep +1 -0
  98. package/npm/darwin-arm64/package.json +25 -0
  99. package/npm/darwin-x64/lib/.gitkeep +1 -0
  100. package/npm/darwin-x64/package.json +25 -0
  101. package/npm/linux-arm64/lib/.gitkeep +1 -0
  102. package/npm/linux-arm64/package.json +26 -0
  103. package/npm/linux-x64/lib/.gitkeep +1 -0
  104. package/npm/linux-x64/package.json +26 -0
  105. package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
  106. package/npm/linuxmusl-x64/package.json +26 -0
  107. package/npm/win32-x64/lib/.gitkeep +1 -0
  108. package/npm/win32-x64/package.json +25 -0
  109. package/package.json +74 -0
  110. package/rosepetal-image-engine/binding.gyp +153 -0
  111. package/rosepetal-image-engine/package.json +19 -0
  112. package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
  113. package/rosepetal-image-engine/src/add-mask.cpp +240 -0
  114. package/rosepetal-image-engine/src/add-masks.cpp +638 -0
  115. package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
  116. package/rosepetal-image-engine/src/blend.cpp +200 -0
  117. package/rosepetal-image-engine/src/concat.cpp +329 -0
  118. package/rosepetal-image-engine/src/crop.cpp +139 -0
  119. package/rosepetal-image-engine/src/draw.cpp +414 -0
  120. package/rosepetal-image-engine/src/filter.cpp +230 -0
  121. package/rosepetal-image-engine/src/filters/kernels.h +171 -0
  122. package/rosepetal-image-engine/src/image-align.cpp +551 -0
  123. package/rosepetal-image-engine/src/main.cpp +36 -0
  124. package/rosepetal-image-engine/src/mosaic.cpp +373 -0
  125. package/rosepetal-image-engine/src/padding.cpp +124 -0
  126. package/rosepetal-image-engine/src/resize.cpp +210 -0
  127. package/rosepetal-image-engine/src/rotate.cpp +177 -0
  128. package/rosepetal-image-engine/src/utils.h +563 -0
  129. package/rosepetal-image-engine/test-formats.js +119 -0
  130. package/scripts/build-opencv-static.ps1 +166 -0
  131. package/scripts/build-opencv-static.sh +147 -0
@@ -0,0 +1,131 @@
1
+ # Image-In Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `image-in` node is the primary entry point for loading images from the filesystem into Node-RED flows. It converts image files into the standardized image object format used throughout the Rosepetal Image Tools ecosystem.
6
+
7
+ **Real-World Applications:**
8
+ - **Photo Processing Workflows**: Load photos for batch editing and enhancement
9
+ - **Computer Vision Pipelines**: Import images for AI/ML analysis and object detection
10
+ - **Web Content Processing**: Load user-uploaded images for processing before storage
11
+ - **Surveillance Systems**: Import images from cameras or storage for analysis
12
+
13
+ ![Image-In Demo](../../../assets/nodes/io/image-in-demo.gif)
14
+
15
+ ## Input/Output Specification
16
+
17
+ ### Inputs
18
+ - (any): Input message that triggers the node (content ignored)
19
+
20
+ ### Outputs
21
+ The node outputs a standardized image object to the configured location:
22
+
23
+ ```javascript
24
+ {
25
+ data: Buffer, // Raw pixel data
26
+ width: number, // Image width in pixels
27
+ height: number, // Image height in pixels
28
+ channels: number, // Channel count (1, 3, 4)
29
+ colorSpace: string, // "GRAY", "RGB", "RGBA", ...
30
+ dtype: string // "uint8" (standard)
31
+ }
32
+ ```
33
+
34
+ ## Configuration Options
35
+
36
+ ### File Path
37
+ - **Type**: String | msg | flow | global (required)
38
+ - **Description**: Path to the image file on the server filesystem
39
+ - **Options**:
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
53
+
54
+ ### Debug Options
55
+ - **Show Loaded Image**: Visual preview of loaded image in Node-RED editor
56
+ - **Debug Width**: Preview image width in pixels (default: 200)
57
+ - **Dynamic Width**: Can be resolved from msg, flow, or global context
58
+ - **Interactive**: Preview appears in Node-RED editor with timing information
59
+
60
+ ## Performance Notes
61
+
62
+ ### Sharp (libvips) Backend Optimization
63
+ - **High-Speed Loading**: Uses Sharp (libvips) for optimized image decoding
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
67
+
68
+ ### Status Display
69
+ The node shows real-time progress and results:
70
+ - **Blue dot**: Reading file
71
+ - **Green dot**: Success with dimensions and timing info
72
+ - **Red ring**: Error with file access or format issues
73
+
74
+ ## Real-World Examples
75
+
76
+ ### Basic Photo Import
77
+ ```
78
+ [Inject] → [Image-In: /photos/vacation.jpg] → [Debug]
79
+ ```
80
+ Load a single photo and inspect its properties.
81
+
82
+ ### Dynamic File Loading
83
+ ```
84
+ [File List] → [Image-In: File Path from msg.imagePath] → [Resize] → [Save]
85
+ ```
86
+ Process multiple files by configuring File Path to use `msg.imagePath` for dynamic file selection.
87
+
88
+ ### Computer Vision Pipeline
89
+ ```
90
+ [Image-In] → [CropBB] → [Filter] → [Analysis]
91
+ ```
92
+ Load images for object detection and post-processing.
93
+
94
+ ### Visual Development
95
+ ```
96
+ [Image-In: Debug enabled] → [Transform] → [Output]
97
+ ```
98
+ Enable debug preview to visually verify image loading and dimensions.
99
+
100
+ ### Batch Processing Setup
101
+ ```
102
+ [Image-In] → [Array-In] → [Array-Out] → [Batch Transform]
103
+ ```
104
+ Collect multiple images into arrays for parallel processing.
105
+
106
+ ## Common Issues & Troubleshooting
107
+
108
+ ### File Access Problems
109
+ - **Issue**: "Cannot access file" warning
110
+ - **Solution**: Verify file path exists and Node-RED has read permissions
111
+ - **Check**: Use absolute paths to avoid relative path confusion
112
+
113
+ ### Unsupported Format
114
+ - **Issue**: Node fails silently or errors
115
+ - **Solution**: Ensure file is in supported format (JPEG, PNG, WebP, BMP)
116
+ - **Check**: Verify file isn't corrupted using image viewer
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
122
+
123
+ ### Path Configuration
124
+ - **Static Path**: Set File Path to string type for fixed file locations
125
+ - **Dynamic Path**: Configure File Path from msg, flow, or global context for runtime file selection
126
+ - **Best Practice**: Validate dynamic path sources provide valid file paths
127
+
128
+ ### Debug Display Issues
129
+ - **Issue**: Debug preview not appearing
130
+ - **Solution**: Ensure debug checkbox is enabled and Node-RED editor is active
131
+ - **Performance**: Large debug widths may impact editor performance
@@ -0,0 +1,179 @@
1
+ # Image-Out Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `image-out` node is the primary output point for saving processed images to the filesystem from Node-RED flows. It features automatic timestamp-based naming, overwrite protection, and flexible format conversion, making it ideal for production workflows.
6
+
7
+ **Real-World Applications:**
8
+ - **Automated Image Processing**: Save processed images with organized timestamp naming
9
+ - **Computer Vision Results**: Export detected objects or processed frames
10
+ - **Batch Processing Workflows**: Save multiple images without filename conflicts
11
+ - **Quality Control Systems**: Archive inspection images with automatic naming
12
+ - **Web Application Backends**: Save user-processed images with format optimization
13
+
14
+ ## Input/Output Specification
15
+
16
+ ### Inputs
17
+ The node accepts either:
18
+ - **Raw Image Object**: Standard format with `data`, `width`, `height`, `channels`, `colorSpace`
19
+ - **Encoded Buffer**: JPEG, PNG, or WebP buffer (automatically detected and handled)
20
+
21
+ ### Outputs
22
+ This is a terminal node with no outputs. It saves images to the filesystem and displays status information.
23
+
24
+ ### Button Control
25
+ - **Right-side button**: Toggle node active/inactive state (similar to debug node)
26
+ - **Green**: Active and saving images
27
+ - **Gray**: Inactive (passes through without saving)
28
+
29
+ ## Configuration Options
30
+
31
+ ### Folder Path
32
+ - **Type**: String | msg | flow | global (required)
33
+ - **Description**: Directory where images will be saved
34
+ - **Options**:
35
+ - **String**: Static path (e.g., `/home/user/output/`)
36
+ - **msg.***: Dynamic path from message (e.g., `msg.folder`)
37
+ - **flow.***: Path from flow context
38
+ - **global.***: Path from global context
39
+ - **Auto-creation**: Directory is created if it doesn't exist
40
+
41
+ ### Filename Prefix
42
+ - **Type**: String (optional)
43
+ - **Default**: "image"
44
+ - **Description**: Custom prefix for generated filenames
45
+ - **Pattern**: `[prefix]_YYYYMMDD_HHMMSS.[ext]`
46
+ - **Example**: With prefix "webcam" → `webcam_20240109_143022.jpg`
47
+
48
+ ### Input From
49
+ - **Default**: `msg.payload`
50
+ - **Options**: Any message property, flow, or global variable
51
+ - **Accepts**: Both raw image objects and encoded buffers
52
+
53
+ ### Output Format
54
+ - **Options**: JPEG, PNG, WebP
55
+ - **Description**: Target format for saved images
56
+ - **Conversion**: Automatic conversion if input format differs
57
+
58
+ ### Quality
59
+ - **Type**: Number (1-100)
60
+ - **Default**: 90
61
+ - **Applies to**: JPEG and WebP formats
62
+ - **Description**: Higher values = better quality but larger files
63
+
64
+ ### PNG Optimize
65
+ - **Type**: Boolean
66
+ - **Default**: false
67
+ - **Description**: Maximum compression for PNG files (slower but smaller)
68
+
69
+ ### Overwrite Protection
70
+ - **Type**: Boolean
71
+ - **Default**: true
72
+ - **Description**: Automatically appends `_2`, `_3`, etc. to prevent overwriting
73
+ - **Example**: If `image_20240109_143022.jpg` exists, saves as `image_20240109_143022_2.jpg`
74
+
75
+ ### Debug Preview
76
+ - **Type**: Boolean
77
+ - **Default**: false
78
+ - **Description**: Shows saved image preview on the node
79
+
80
+ ## Performance & Technical Details
81
+
82
+ ### Timestamp Naming
83
+ Files are automatically named with timestamps:
84
+ - **Format**: `YYYYMMDD_HHMMSS`
85
+ - **Example**: `image_20240109_143022.jpg`
86
+ - **Benefits**: Chronological ordering, no conflicts, easy sorting
87
+
88
+ ### Format Handling
89
+ The node intelligently handles format conversions:
90
+ - **Same Format**: Direct save without re-encoding (fastest)
91
+ - **Different Format**: Automatic conversion using Sharp
92
+ - **Raw to Encoded**: Full processing with color space handling
93
+ - **Encoded to Encoded**: Smart re-encoding only when needed
94
+
95
+ ### Status Indicators
96
+ - **Gray dot "inactive"**: Node disabled via button
97
+ - **Blue dot "saving..."**: Currently writing to disk
98
+ - **Green dot "saved: filename.jpg"**: Success with filename
99
+ - **Red dot "Error"**: Save failed (check debug panel)
100
+
101
+ ## Error Handling
102
+
103
+ Common errors and solutions:
104
+ - **"Folder path not configured"**: Ensure folder path is set
105
+ - **"Invalid image structure"**: Check input is valid image data
106
+ - **"Cannot create directory"**: Verify write permissions
107
+ - **"Too many file variations"**: Clean up old files (>1000 with same timestamp)
108
+
109
+ ## Examples
110
+
111
+ ### Basic Save with Timestamp
112
+ ```javascript
113
+ // Input: Processed image
114
+ // Config: Folder="/output", Format="jpg"
115
+ // Result: /output/image_20240109_143022.jpg
116
+ ```
117
+
118
+ ### Custom Prefix for Source Identification
119
+ ```javascript
120
+ // Config: Prefix="camera1", Folder="/surveillance"
121
+ // Result: /surveillance/camera1_20240109_143022.jpg
122
+ ```
123
+
124
+ ### Format Conversion
125
+ ```javascript
126
+ // Input: PNG buffer
127
+ // Config: Format="webp", Quality=80
128
+ // Result: Converts PNG to WebP with 80% quality
129
+ ```
130
+
131
+ ### Dynamic Folder from Message
132
+ ```javascript
133
+ // msg.saveFolder = "/output/batch1"
134
+ // Config: Folder from msg.saveFolder
135
+ // Result: Saves to dynamic folder location
136
+ ```
137
+
138
+ ### Overwrite Protection in Action
139
+ ```javascript
140
+ // First save: image_20240109_143022.jpg
141
+ // Second save (same second): image_20240109_143022_2.jpg
142
+ // Third save: image_20240109_143022_3.jpg
143
+ ```
144
+
145
+ ## Tips & Best Practices
146
+
147
+ 1. **Use Prefixes**: Identify image sources with meaningful prefixes
148
+ 2. **Enable Protection**: Keep overwrite protection on to prevent data loss
149
+ 3. **Choose Format Wisely**:
150
+ - JPEG for photos (smaller files)
151
+ - PNG for graphics with transparency
152
+ - WebP for web optimization
153
+ 4. **Button Control**: Disable during development to prevent unwanted saves
154
+ 5. **Monitor Status**: Check node status for save confirmations
155
+
156
+ ## Integration Examples
157
+
158
+ ### Computer Vision Pipeline
159
+ ```
160
+ [Camera] → [Object Detection] → [Draw Boxes] → [Image-Out]
161
+ ```
162
+ Save annotated detection results with timestamps.
163
+
164
+ ### Batch Processing
165
+ ```
166
+ [Image-In] → [Array-Out] → [Transform] → [Image-Out]
167
+ ```
168
+ Process and save multiple images with automatic naming.
169
+
170
+ ### Quality Control
171
+ ```
172
+ [Inspection Camera] → [Defect Detection] → [Image-Out (active/inactive)]
173
+ ```
174
+ Conditionally save images based on detection results.
175
+
176
+ ## Related Nodes
177
+ - **[image-in](image-in.md)**: Load images from filesystem
178
+ - **[array-out](array-out.md)**: Process multiple images before saving
179
+ - **[filter](../transform/filter.md)**: Apply enhancements before saving
@@ -0,0 +1,57 @@
1
+ # Queue Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `queue` node buffers incoming messages, enforces a minimum interval between outputs, and discards stale entries. It helps coordinate bursty producers with slower consumers by smoothing throughput and avoiding overload.
6
+
7
+ **Common Scenarios:**
8
+ - Throttle high-frequency image sources before storage or slow analysis stages
9
+ - Prevent downstream rate limits from being exceeded when batch processing arrays
10
+ - Provide simple back-pressure where only a fixed number of messages can be buffered
11
+ - Drop stale detections or frames that are no longer relevant after a timeout
12
+
13
+ ## Input/Output Specification
14
+
15
+ ### Inputs
16
+ - **Incoming Message**: Any Node-RED message to be enqueued.
17
+
18
+ ### Outputs
19
+ - **Queued Message**: Messages are forwarded in FIFO order while respecting the configured interval.
20
+
21
+ When timeout mode is selected, messages that exceed the configured timeout are silently discarded with a warning in the node's log.
22
+
23
+ ## Configuration Options
24
+
25
+ ### Mode
26
+ - **Type**: Dropdown (`Queue Size Limit` / `Timeout`)
27
+ - **Default**: `Queue Size Limit`
28
+ - **Purpose**: Select whether the node enforces a hard buffer capacity or lets messages expire after a timeout; the controls shown below change depending on the selected mode.
29
+
30
+ ### Queue Size Limit
31
+ - **Type**: Number (integer)
32
+ - **Default**: `0` (no limit)
33
+ - **Purpose**: Available only in queue-size mode. Controls how many messages may be enqueued before excess messages are ignored.
34
+
35
+ ### Timeout (ms)
36
+ - **Type**: Number (integer)
37
+ - **Default**: `0` (no timeout)
38
+ - **Purpose**: Available only in timeout mode. Messages that stay longer than this duration are removed before they reach the output.
39
+
40
+ ### Interval (ms)
41
+ - **Type**: Number (integer)
42
+ - **Default**: `0` (no enforced delay)
43
+ - **Purpose**: Minimum time that must elapse between forwarded messages. When set to 0, messages flow out as soon as they are available.
44
+
45
+ ## Behavior & Status
46
+
47
+ - Messages are processed in first-in-first-out order.
48
+ - The node emits messages immediately when the interval requirement has already been satisfied.
49
+ - If necessary, the node waits the remaining interval before releasing the next message.
50
+ - When messages expire due to timeout (and timeout mode is active) they are removed from the queue and a warning is logged.
51
+ - Node status indicates whether the queue is idle, holding messages, or actively sending.
52
+
53
+ ## Best Practices
54
+
55
+ - Pair with Array nodes to control the rate of batch processing pipelines.
56
+ - Use timeouts to keep sensor readings or camera frames current.
57
+ - Combine with Catch or Status nodes to monitor when the queue reaches capacity or drops messages.
@@ -0,0 +1,30 @@
1
+ # save-file
2
+
3
+ Write incoming data to disk as an image, JSON, text, or binary file. The node can auto-detect the best mode from the payload or a provided filename/extension.
4
+
5
+ ## Inputs
6
+ - **payload** (default): Data to write. Supports raw image objects (`{data,width,height,channels,colorSpace}`), encoded image buffers, plain objects/arrays, strings, or buffers.
7
+ - **Alternative path**: Use the *Input* field to read from any `msg`/`flow`/`global` property.
8
+
9
+ ## Properties
10
+ - **Folder** (*str | env | msg | flow | global*) – Destination directory. Created if missing.
11
+ - **Filename** (*str | msg | flow | global*) – Optional name without path separators. If left blank, a timestamped name is generated. If you include an extension here, it is respected.
12
+ - **File Type** (*auto | image | json | text | binary*) – Force the save mode or let the node decide. Auto uses the extension, raw image structure, or Sharp metadata for buffers.
13
+ - **Image Format** (*jpg | png | webp*) – Encoding for image saves. Quality and PNG optimization are available.
14
+ - **JSON Indent** – Spacing for pretty-printed JSON output.
15
+ - **Overwrite protection** – Enabled by default; adds a numeric suffix when the file already exists.
16
+ - **Result to** – Where to store summary metadata `{ path, filename, type, extension, sizeBytes, format? }` (default `msg.savedFile`).
17
+
18
+ ## Behavior
19
+ - Raw image inputs are validated and encoded with Sharp; BGR/BGRA channels are auto-swapped.
20
+ - JSON inputs are pretty-printed; valid JSON strings are kept as-is.
21
+ - Text mode writes stringified content; binary mode writes buffers directly (or stringified when not a buffer).
22
+ - When overwrite protection is enabled, the node keeps adding `_<n>` until a free filename is found.
23
+
24
+ ## Status
25
+ - Shows the final filename, duration, and whether an overwrite was avoided.
26
+
27
+ ## Example flows
28
+ - Save final inference results as `results.json` in `/data/out`.
29
+ - Persist camera frames as WebP by setting *File Type = image* and *Image Format = webp*.
30
+ - Archive arbitrary payloads by pointing *Input* to `msg.myBuffer` and enabling overwrite protection.
@@ -0,0 +1,108 @@
1
+ # Advanced Mosaic Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `advanced-mosaic` node provides sophisticated layout capabilities beyond basic grids, supporting custom positioning, variable cell sizes, and complex arrangement patterns. It enables pixel-perfect control over image placement for professional layouts and artistic compositions.
6
+
7
+ **Real-World Applications:**
8
+ - **Magazine Layouts**: Create complex editorial layouts with varying image sizes
9
+ - **Web Design Mockups**: Arrange elements in custom positions for design prototypes
10
+ - **Artistic Compositions**: Create asymmetric, visually interesting image arrangements
11
+ - **Dashboard Design**: Position charts and data visualizations with precise control
12
+ - **Poster Creation**: Design promotional materials with sophisticated image arrangements
13
+
14
+ *[PLACEHOLDER - Add GIF showing complex layouts with custom positioning and variable cell sizes]*
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Image Array**: Array of image objects with optional position metadata
20
+ - **Layout Configuration**: Custom positioning data via message properties or configuration
21
+ - **Canvas Parameters**: Target canvas dimensions and layout constraints
22
+
23
+ ### Outputs
24
+ - **Complex Layout**: Single composite image with precisely positioned elements
25
+ - **Custom Canvas**: Canvas sized according to layout requirements or fixed dimensions
26
+ - **Format Options**: Raw image object or encoded file formats
27
+ - **Mask Propagation (optional)**: When enabled, a second output array containing masks transformed with the exact same resize/rotate/position steps. Each mask index aligns with the source image index and is ready for downstream drawing/overlay nodes.
28
+
29
+ ## Configuration Options
30
+
31
+ ### Input/Output Paths
32
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
33
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
34
+
35
+ ### Canvas Configuration
36
+
37
+ #### Canvas Size
38
+ - **Fixed Dimensions**: Specify exact width and height
39
+ - **Auto Size**: Calculate canvas size based on image positions and sizes
40
+ - **Aspect Ratio**: Maintain specific aspect ratio while auto-sizing
41
+
42
+ #### Background Settings
43
+ - **Background Color**: Color for empty canvas areas
44
+ - **Background Image**: Use image as background behind positioned elements
45
+ - **Transparency**: Support for transparent backgrounds (PNG output)
46
+
47
+ ### Positioning System
48
+
49
+ #### Position Modes
50
+ - **Absolute**: X,Y coordinates in pixels
51
+ - **Relative**: Positions as percentages of canvas size (0-1)
52
+ - **Grid-Based**: Enhanced grid system with custom cell sizes
53
+ - **Flow Layout**: Automatic positioning with spacing rules
54
+
55
+ #### Position Sources
56
+ - **Configuration**: Set positions in node editor
57
+ - **Message Data**: Position data provided per image in input array
58
+ - **Dynamic Calculation**: Calculate positions using function nodes
59
+
60
+ ### Advanced Layout Features
61
+
62
+ #### Variable Cell Sizes
63
+ - **Custom Width/Height**: Each image can have different cell dimensions
64
+ - **Aspect Ratio Preservation**: Maintain image proportions within custom cells
65
+ - **Scaling Options**: Fit, fill, or stretch images within designated areas
66
+
67
+ #### Layering and Z-Order
68
+ - **Layer Control**: Specify which images appear above others
69
+ - **Overlap Handling**: Manage overlapping elements gracefully
70
+ - **Transparency Support**: Proper alpha blending for overlapping areas
71
+
72
+ ### Output Format Options
73
+ - **Raw**: Standard image object (fastest for processing chains)
74
+ - **JPEG**: Compressed (transparency becomes background color)
75
+ - **PNG**: Full transparency and quality preservation
76
+ - **WebP**: Modern format with transparency and compression
77
+ - **Mask Propagation**: Enable the *Propagate masks* checkbox to feed a mask array (one per input image index). The node applies the same resize/rotate/position to each mask and emits a transformed mask array for downstream overlay/drawing without manual conversions.
78
+
79
+ ## Mask Propagation Input Format
80
+
81
+ When *Propagate masks* is enabled, supply `msg.masks` (or the configured path) as an **array aligned to the input images array**. Index `i` is the mask for image `i`. Each entry can be one of:
82
+
83
+ - **Polygon mask**: `{ tag?: "class", polygons: [ [ [x,y], [x,y], ... ] , ... ] }` where points are normalized 0–1.
84
+ - **Raw mask image**: `{ mask: { data, width, height, channels, colorSpace, dtype } , tag?: "class" }` (RGBA/LA/GRAY accepted; alpha preferred).
85
+ - **2D matrix mask**: `{ mask: [[0,1,1,...], ...], tag?: "class" }` or simply a 2D/array-of-2D numeric matrix.
86
+
87
+ Rules:
88
+ - Array length should match the images array; missing entries are ignored.
89
+ - `tag`/`class`/`class_name`/`label` are passed through if present.
90
+ - Masks are binarized, resized with `INTER_NEAREST`, rotated, and positioned exactly like their source image. The output `masks` array mirrors the input order and is ready for downstream drawing nodes.
91
+
92
+ ## Performance Notes
93
+
94
+ ### C++ Backend Processing
95
+ - **Optimized Rendering**: Efficient composite rendering with layer management
96
+ - **Memory Management**: Smart memory allocation for complex layouts
97
+ - **Overlap Detection**: Optimized algorithms for handling overlapping elements
98
+ - **High-Quality Scaling**: Professional-grade scaling for variable-sized elements
99
+
100
+ ### Layout Engine
101
+ - **Position Validation**: Automatic bounds checking and constraint handling
102
+ - **Layer Ordering**: Efficient z-order processing for overlapping elements
103
+ - **Canvas Optimization**: Minimal canvas size calculation for auto-sizing modes
104
+
105
+ ## Real-World Examples
106
+
107
+ ### Magazine Article Layout
108
+ ```javascript\n// In function node: set custom positions for magazine layout\nmsg.images.forEach((img, i) => {\n if (i === 0) { // Hero image\n img.position = { x: 0, y: 0, width: 800, height: 400 };\n } else if (i === 1) { // Side image\n img.position = { x: 820, y: 0, width: 300, height: 200 };\n } else { // Thumbnail strip\n img.position = { x: 100 * i, y: 420, width: 80, height: 80 };\n }\n});\n```\nCreate professional magazine-style layouts with hero images and supporting visuals.\n\n### Dashboard Layout\n```\n[Chart Images] → [Function: Set Positions] → [Advanced Mosaic: Custom layout] → [Dashboard]\n```\nPosition charts, graphs, and KPI displays in precise dashboard arrangements.\n\n### Product Showcase\n```javascript\n// Custom product display with hero and detail shots\nmsg.productImages[0].position = { x: 0, y: 0, width: 600, height: 600 }; // Main product\nmsg.productImages[1].position = { x: 620, y: 0, width: 280, height: 200 }; // Detail 1\nmsg.productImages[2].position = { x: 620, y: 220, width: 280, height: 200 }; // Detail 2\nmsg.productImages[3].position = { x: 620, y: 440, width: 280, height: 160 }; // Detail 3\n```\n\n### Artistic Collage Creation\n```\n[Art Images] → [Function: Random Positions] → [Advanced Mosaic: Overlap enabled] → [Artistic Collage]\n```\nCreate visually interesting overlapping compositions with controlled randomness.\n\n### Web Design Mockup\n```\n[UI Elements] → [Function: Responsive Positions] → [Advanced Mosaic: Fixed canvas] → [Mockup]\n```\nArrange UI elements for web design prototypes and mockups.\n\n## Common Issues & Troubleshooting\n\n### Position Conflicts\n- **Issue**: Images overlapping unintentionally or awkward positioning\n- **Solution**: Validate position calculations and implement collision detection\n- **Prevention**: Use position validation functions before processing\n\n### Canvas Size Problems\n- **Issue**: Canvas too small for positioned elements or excessive whitespace\n- **Solution**: Use auto-sizing or carefully calculate required canvas dimensions\n- **Planning**: Consider element positions and sizes when planning canvas\n\n### Performance with Complex Layouts\n- **Issue**: Slow processing with many overlapping elements\n- **Optimization**: Minimize unnecessary overlaps, use appropriate image sizes\n- **Monitoring**: Track processing times and optimize layout complexity\n\n### Memory Issues\n- **Issue**: Large canvases with high-resolution images consume excessive memory\n- **Solution**: Use appropriately sized images for final output requirements\n- **Strategy**: Consider final display size when sizing source images\n\n## Integration Patterns\n\n### Professional Layout Workflow\n```\nContent → Analyze Layout → Calculate Positions → Advanced Mosaic → Output\n```\nAutomated professional layout generation based on content analysis.\n\n### Interactive Design System\n```\nUser Input → Position Calculator → Advanced Mosaic → Preview → Iterate\n```\nInteractive layout system for design applications.\n\n### Template-Based Generation\n```\nLayout Template → Apply to Content → Advanced Mosaic → Branded Output\n```\nUse predefined templates for consistent branded layouts.\n\n### Responsive Layout System\n```\nContent → Detect Screen Size → Calculate Responsive Positions → Advanced Mosaic → Adaptive Output\n```\nCreate layouts that adapt to different output dimensions.\n\n## Advanced Usage\n\n### Template-Based Positioning\n```javascript\n// Define layout templates\nconst templates = {\n hero: {\n main: { x: 0, y: 0, width: 0.7, height: 1.0 },\n sidebar: [ \n { x: 0.72, y: 0, width: 0.28, height: 0.3 },\n { x: 0.72, y: 0.32, width: 0.28, height: 0.3 },\n { x: 0.72, y: 0.64, width: 0.28, height: 0.36 }\n ]\n },\n grid: {\n // Define grid-based template\n }\n};\n\nmsg.layout = templates[msg.layoutType];\n```\n\n### Responsive Position Calculation\n```javascript\n// Calculate positions based on canvas size\nfunction calculateResponsivePositions(images, canvasWidth, canvasHeight) {\n return images.map((img, i) => {\n // Implement responsive positioning logic\n const position = {\n x: Math.floor((i % 3) * canvasWidth / 3),\n y: Math.floor(Math.floor(i / 3) * canvasHeight / 3),\n width: canvasWidth / 3 - 10,\n height: canvasHeight / 3 - 10\n };\n return { ...img, position };\n });\n}\n```\n\n### Overlap Management\n```javascript\n// Detect and resolve position conflicts\nfunction resolveOverlaps(elements) {\n for (let i = 0; i < elements.length; i++) {\n for (let j = i + 1; j < elements.length; j++) {\n if (elementsOverlap(elements[i], elements[j])) {\n // Implement overlap resolution strategy\n adjustPosition(elements[j], elements[i]);\n }\n }\n }\n return elements;\n}\n```\n\n### Dynamic Layout Optimization\n```javascript\n// Optimize layout based on content analysis\nfunction optimizeLayout(images, canvasSize) {\n // Analyze image importance, size requirements, etc.\n const important = images.filter(img => img.priority === 'high');\n const secondary = images.filter(img => img.priority === 'medium');\n const background = images.filter(img => img.priority === 'low');\n \n // Position important images first, then fill with secondary\n return arrangeByPriority(important, secondary, background, canvasSize);\n}\n```\n\n## Best Practices\n\n### Layout Design\n- Plan layouts on paper or design tools before implementing\n- Use consistent spacing and alignment principles\n- Consider visual hierarchy and reading patterns\n- Test layouts with different content variations\n\n### Position Management\n- Use relative positioning for responsive layouts\n- Implement position validation to prevent errors\n- Consider overlap handling strategies from the start\n- Document position calculation logic for maintenance\n\n### Performance Optimization\n- Use appropriate image sizes for final output requirements\n- Minimize unnecessary overlapping elements\n- Consider memory implications of large canvas sizes\n- Profile performance with realistic content loads\n\n### Quality Considerations\n- Use high-quality source images for scaling operations\n- Choose appropriate output formats for intended use\n- Consider compression settings for web vs. print\n- Test final output in intended display environment\n\n### Development Workflow\n- Start with simple positioning and add complexity gradually\n- Use debug output to verify position calculations\n- Implement position validation and error handling\n- Create reusable positioning templates for consistency
@@ -0,0 +1,127 @@
1
+ # Concat Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `concat` node combines multiple images horizontally or vertically into a single composite image. It automatically handles alignment and supports flexible input formats for creating image strips, panoramas, and comparison layouts.
6
+
7
+ **Real-World Applications:**
8
+ - **Before/After Comparisons**: Side-by-side image comparisons for treatments, edits, or changes
9
+ - **Product Catalogs**: Create product strips showing multiple views or variations
10
+ - **Social Media Content**: Combine multiple images for Instagram carousels or stories
11
+ - **Progress Documentation**: Show step-by-step processes or time-lapse sequences
12
+ - **Report Generation**: Combine charts, photos, and diagrams into unified layouts
13
+
14
+ ![Concat Demo](../../../assets/nodes/mix/concat-demo.gif)
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Image Array**: Array of image objects to combine
20
+
21
+ ### Outputs
22
+ - **Combined Image**: Single image containing all input images arranged in sequence
23
+ - **Expanded Dimensions**: Width or height increased to accommodate all images
24
+ - **Format Options**: Raw image object or encoded file formats
25
+
26
+ ## Configuration Options
27
+
28
+ ### Input/Output Paths
29
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
30
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
31
+
32
+ ### Direction Options
33
+ - **Right**: Images arranged left-to-right horizontally (width increases)
34
+ - **Left**: Images arranged right-to-left horizontally (width increases)
35
+ - **Down**: Images stacked top-to-bottom vertically (height increases)
36
+ - **Up**: Images stacked bottom-to-top vertically (height increases)
37
+
38
+ ### Strategy Options
39
+
40
+ #### Padding Strategies (for dimension mismatches)
41
+ - **pad-start**: Add padding at beginning of smaller images
42
+ - **pad-end**: Add padding at end of smaller images
43
+ - **pad-both**: Center smaller images with padding on both sides
44
+ - **resize**: Resize all images to match largest dimension
45
+
46
+ ### Color Configuration
47
+ - **Padding Color**: Background color for padding areas when images have different sizes
48
+ - **Default**: Black
49
+ - **Formats**: RGB (`rgb(255,0,0)`)
50
+
51
+ ### Output Format Options
52
+ - **Raw**: Standard image object (fastest for processing chains)
53
+ - **JPEG**: Compressed with quality control
54
+ - **PNG**: Lossless with transparency support
55
+ - **WebP**: Modern format with excellent compression
56
+
57
+ ## Performance Notes
58
+
59
+ ### C++ Backend Processing
60
+ - **Optimized Composition**: Efficient memory allocation for composite canvas
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
64
+
65
+ ### Dimension Handling
66
+ - **Automatic Sizing**: Canvas automatically sized to fit all images
67
+ - **Alignment Compensation**: Background fill for dimension mismatches
68
+ - **Memory Efficiency**: Pre-calculates final dimensions to minimize allocations
69
+
70
+ ## Real-World Examples
71
+
72
+ ### Before/After Comparison
73
+ ```
74
+ [Original Image] → [Array-In: pos=0] ┐
75
+ [Processed Image] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Right, Strategy=pad-both] → [Comparison Strip]
76
+ ```
77
+ Create side-by-side before/after comparisons with centered alignment.
78
+
79
+ ### Product Catalog Strip
80
+ ```
81
+ [Product Photos Array] → [Concat: Direction=Right, Strategy=resize] → [Catalog Strip]
82
+ ```
83
+ Combine multiple product views, resizing to uniform height.
84
+
85
+ ### Progress Timeline
86
+ ```
87
+ [Step 1 Image] → [Array-In: pos=0] ┐
88
+ [Step 2 Image] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Direction=Down, Strategy=pad-both] → [Process Timeline]
89
+ [Step 3 Image] → [Array-In: pos=2] ┘
90
+ ```
91
+ Document multi-step processes vertically with centered alignment.
92
+
93
+ ### Social Media Carousel
94
+ ```
95
+ [Image Array] → [Resize: Same height] → [Concat: Direction=Right, Strategy=pad-start] → [Carousel Image]
96
+ ```
97
+ Create horizontal image strips for social media.
98
+
99
+ ### Report Layout
100
+ ```
101
+ [Chart Image] → [Array-In: pos=0] ┐
102
+ [Photo Evidence] → [Array-In: pos=1] ├→ [Array-Out] → [Concat: Vertical] → [Report Section]
103
+ [Data Table] → [Array-In: pos=2] ┘
104
+ ```
105
+ Combine different types of visual content into reports.
106
+
107
+ ## Common Issues & Troubleshooting
108
+
109
+ ### Dimension Mismatches
110
+ - **Issue**: Images with different sizes create alignment problems
111
+ - **Solution**: Use resize node to standardize dimensions before concat
112
+ - **Alternative**: Use appropriate alignment settings to handle size differences
113
+
114
+ ### Memory Usage with Large Images
115
+ - **Issue**: Concatenating many large images uses significant memory
116
+ - **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
+
124
+ ### Color Consistency
125
+ - **Issue**: Images have different color profiles or brightness
126
+ - **Preprocessing**: Apply consistent color correction before concatenation
127
+ - **Solution**: Use filter nodes to normalize appearance