@rosepetal/node-red-contrib-image-tools 1.2.3 → 1.3.0
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 +3 -0
- package/install.sh +8 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +219 -3
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +2 -1
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +258 -3
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +2 -1
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +183 -3
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +2 -1
- package/node-red-contrib-image-tools/nodes/blend/blend.html +308 -3
- package/node-red-contrib-image-tools/nodes/blend/blend.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +147 -3
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/image-in.html +81 -2
- package/node-red-contrib-image-tools/nodes/io/image-in.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/image-out.html +197 -3
- package/node-red-contrib-image-tools/nodes/io/image-out.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +375 -3
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/concat.html +222 -5
- package/node-red-contrib-image-tools/nodes/mix/concat.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +284 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +2 -1
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +193 -3
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +2 -1
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +260 -2
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/color-convert.html +144 -5
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/crop.html +213 -5
- package/node-red-contrib-image-tools/nodes/transform/crop.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/draw.html +128 -3
- package/node-red-contrib-image-tools/nodes/transform/draw.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/filter.html +344 -3
- package/node-red-contrib-image-tools/nodes/transform/filter.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/padding.html +292 -5
- package/node-red-contrib-image-tools/nodes/transform/padding.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/resize.html +177 -3
- package/node-red-contrib-image-tools/nodes/transform/resize.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +140 -5
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +2 -1
- package/package.json +71 -71
- package/scripts/dual-register.js +267 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
|
|
2
|
+
var _rpNodeCfg = {
|
|
3
3
|
category : 'RP Image',
|
|
4
4
|
color : '#DDA0DD',
|
|
5
5
|
defaults : {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
inputs :1, outputs:1,
|
|
24
24
|
icon:"font-awesome/fa-eyedropper",
|
|
25
|
-
label:function(){ return this.name || "color-convert"; },
|
|
25
|
+
label:function(){ return this.name || "rp-color-convert"; },
|
|
26
26
|
|
|
27
27
|
oneditprepare:function(){
|
|
28
28
|
$("#node-input-inputPath").typedInput({default:'msg',types:['msg','flow','global'],typeField:"#node-input-inputPathType"});
|
|
@@ -72,10 +72,12 @@
|
|
|
72
72
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
};
|
|
76
|
+
RED.nodes.registerType('rp-color-convert', _rpNodeCfg);
|
|
77
|
+
RED.nodes.registerType('color-convert', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
76
78
|
</script>
|
|
77
79
|
|
|
78
|
-
<script type="text/x-red" data-template-name="color-convert">
|
|
80
|
+
<script type="text/x-red" data-template-name="rp-color-convert">
|
|
79
81
|
<div class="form-row"><label for="node-input-name"><i class="fa fa-tag"></i> Name</label><input type="text" id="node-input-name"></div>
|
|
80
82
|
<hr>
|
|
81
83
|
<div class="form-row"><label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input</label><input type="text" id="node-input-inputPath" style="width:70%;"><input type="hidden" id="node-input-inputPathType"></div>
|
|
@@ -141,7 +143,144 @@
|
|
|
141
143
|
</div>
|
|
142
144
|
</script>
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
<script type="text/x-red" data-template-name="color-convert">
|
|
147
|
+
<div class="form-row"><label for="node-input-name"><i class="fa fa-tag"></i> Name</label><input type="text" id="node-input-name"></div>
|
|
148
|
+
<hr>
|
|
149
|
+
<div class="form-row"><label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input</label><input type="text" id="node-input-inputPath" style="width:70%;"><input type="hidden" id="node-input-inputPathType"></div>
|
|
150
|
+
<div class="form-row"><label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output</label><input type="text" id="node-input-outputPath" style="width:70%;"><input type="hidden" id="node-input-outputPathType"></div>
|
|
151
|
+
<div class="form-row">
|
|
152
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
153
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
154
|
+
<option value="raw">Raw (fastest)</option>
|
|
155
|
+
<option value="jpg">JPEG</option>
|
|
156
|
+
<option value="png">PNG</option>
|
|
157
|
+
<option value="webp">WebP</option>
|
|
158
|
+
</select>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="form-row" id="quality-row">
|
|
161
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
162
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
163
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
166
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
167
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
168
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
169
|
+
</div>
|
|
170
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
171
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
172
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
173
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
176
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
177
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
178
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
179
|
+
</div>
|
|
180
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
181
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
182
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
183
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<!-- Debug Configuration -->
|
|
187
|
+
<div class="form-row">
|
|
188
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
189
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
190
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
191
|
+
</div>
|
|
192
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
193
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
194
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
195
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
196
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<hr>
|
|
200
|
+
<div class="form-row">
|
|
201
|
+
<label for="node-input-targetColorSpace"><i class="fa fa-paint-brush"></i> Target Color Space</label>
|
|
202
|
+
<select id="node-input-targetColorSpace" style="width: 200px;">
|
|
203
|
+
<option value="GRAY">Grayscale (GRAY)</option>
|
|
204
|
+
<option value="RGB">RGB</option>
|
|
205
|
+
<option value="RGBA">RGBA</option>
|
|
206
|
+
<option value="BGR">BGR</option>
|
|
207
|
+
<option value="BGRA">BGRA</option>
|
|
208
|
+
</select>
|
|
209
|
+
</div>
|
|
210
|
+
</script>
|
|
211
|
+
|
|
212
|
+
<script type="text/x-red" data-help-name="rp-color-convert">
|
|
213
|
+
<p>Converts images between color spaces (GRAY, RGB, RGBA, BGR, BGRA) using high-performance C++ processing.</p>
|
|
214
|
+
|
|
215
|
+
<h3>Details</h3>
|
|
216
|
+
<p>This node converts images from one color space to another. The source color space is automatically detected from the input image metadata (or inferred from channel count). The target color space is selected in the node configuration. Supports both single images and arrays, processed in parallel.</p>
|
|
217
|
+
|
|
218
|
+
<h3>Properties</h3>
|
|
219
|
+
<dl class="message-properties">
|
|
220
|
+
<dt>Input from <span class="property-type">string</span></dt>
|
|
221
|
+
<dd>The location to read image data from. You can select between <code>msg</code>, <code>flow</code>, or <code>global</code> context. Defaults to <code>msg.payload</code>.</dd>
|
|
222
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
223
|
+
<dd>The location where the converted image will be stored. You can select between <code>msg</code>, <code>flow</code>, or <code>global</code> context. Defaults to <code>msg.payload</code>.</dd>
|
|
224
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
225
|
+
<dd>Choose output format: <code>raw</code> (fastest, standard image object), <code>jpg</code>, <code>png</code>, or <code>webp</code> (encoded file buffers).</dd>
|
|
226
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
227
|
+
<dd>Compression quality for JPEG and WebP formats (1-100). Only visible when jpg or webp format is selected. Default: 90.</dd>
|
|
228
|
+
<dt>Target Color Space <span class="property-type">string</span></dt>
|
|
229
|
+
<dd>The target color space to convert images to. Options: <code>GRAY</code>, <code>RGB</code>, <code>RGBA</code>, <code>BGR</code>, <code>BGRA</code>. Default: RGB.</dd>
|
|
230
|
+
</dl>
|
|
231
|
+
|
|
232
|
+
<h3>Inputs</h3>
|
|
233
|
+
<dl class="message-properties">
|
|
234
|
+
<dt>payload <span class="property-type">object | array</span></dt>
|
|
235
|
+
<dd>Single image object or array of image objects in standard format: <code>{ data: Buffer, width: number, height: number, channels: number, colorSpace: string, dtype: string }</code></dd>
|
|
236
|
+
</dl>
|
|
237
|
+
|
|
238
|
+
<h3>Outputs</h3>
|
|
239
|
+
<dl class="message-properties">
|
|
240
|
+
<dt>payload <span class="property-type">object | array | Buffer</span></dt>
|
|
241
|
+
<dd>Converted image(s). Format depends on Output Format setting: raw image object(s) or encoded file buffer(s).</dd>
|
|
242
|
+
</dl>
|
|
243
|
+
|
|
244
|
+
<h3>Supported Conversions</h3>
|
|
245
|
+
<p>All 20 conversion paths between the 5 color spaces are supported:</p>
|
|
246
|
+
<ul>
|
|
247
|
+
<li><strong>GRAY →</strong> BGR, RGB, BGRA, RGBA</li>
|
|
248
|
+
<li><strong>BGR →</strong> GRAY, RGB, BGRA, RGBA</li>
|
|
249
|
+
<li><strong>RGB →</strong> GRAY, BGR, BGRA, RGBA</li>
|
|
250
|
+
<li><strong>BGRA →</strong> GRAY, BGR, RGB, RGBA</li>
|
|
251
|
+
<li><strong>RGBA →</strong> GRAY, BGR, RGB, BGRA</li>
|
|
252
|
+
</ul>
|
|
253
|
+
<p>If the source and target color space are the same, a fast passthrough is used (no conversion overhead).</p>
|
|
254
|
+
|
|
255
|
+
<h3>Examples</h3>
|
|
256
|
+
<ul>
|
|
257
|
+
<li><strong>RGB → GRAY:</strong> Convert a color image to grayscale (3 channels → 1 channel)</li>
|
|
258
|
+
<li><strong>GRAY → RGBA:</strong> Expand grayscale to RGBA with full alpha (1 channel → 4 channels)</li>
|
|
259
|
+
<li><strong>BGR → RGB:</strong> Swap blue and red channels for display compatibility</li>
|
|
260
|
+
<li><strong>RGB → BGRA:</strong> Add alpha channel and convert to OpenCV-native order</li>
|
|
261
|
+
</ul>
|
|
262
|
+
|
|
263
|
+
<h3>Node Interactions</h3>
|
|
264
|
+
<p><strong>Input Sources:</strong> Image-in, Array-out, other transform nodes</p>
|
|
265
|
+
<p><strong>Output Destinations:</strong> Other transform nodes, Mix nodes (concat, mosaic), Array-in for collections</p>
|
|
266
|
+
<p><strong>Common Workflows:</strong> Preparing images for specific processing pipelines, ensuring consistent color spaces before blending or concatenation</p>
|
|
267
|
+
|
|
268
|
+
<h3>Output Formats</h3>
|
|
269
|
+
<ul>
|
|
270
|
+
<li><strong>Raw:</strong> Standard image object (fastest, for further processing)</li>
|
|
271
|
+
<li><strong>JPEG:</strong> Compressed file buffer with quality setting</li>
|
|
272
|
+
<li><strong>PNG:</strong> Lossless compressed file buffer</li>
|
|
273
|
+
<li><strong>WebP:</strong> Modern compressed format with quality setting</li>
|
|
274
|
+
</ul>
|
|
275
|
+
|
|
276
|
+
<h3>Error Handling</h3>
|
|
277
|
+
<p>The node validates input data and displays warnings for invalid inputs. Unsupported conversion paths produce descriptive error messages. Processing errors are logged and the original message is passed through with error details.</p>
|
|
278
|
+
|
|
279
|
+
<h3>Performance</h3>
|
|
280
|
+
<p>Uses optimized C++ backend with OpenCV for high-performance color space conversion. Identity conversions (same source/target) use a zero-cost passthrough. Node status displays processing time. Array inputs are processed in parallel for optimal performance.</p>
|
|
281
|
+
</script>
|
|
282
|
+
|
|
283
|
+
<script type="text/x-red" data-help-name="color-convert">
|
|
145
284
|
<p>Converts images between color spaces (GRAY, RGB, RGBA, BGR, BGRA) using high-performance C++ processing.</p>
|
|
146
285
|
|
|
147
286
|
<h3>Details</h3>
|
|
@@ -157,5 +157,6 @@ module.exports = function (RED) {
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
RED.nodes.registerType('color-convert', ColorConvertNode);
|
|
160
|
+
RED.nodes.registerType('rp-color-convert', ColorConvertNode);
|
|
161
|
+
RED.nodes.registerType('color-convert', ColorConvertNode); // legacy compat
|
|
161
162
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- 1 ▸ Runtime registration -->
|
|
4
4
|
<script type="text/javascript">
|
|
5
|
-
|
|
5
|
+
var _rpNodeCfg = {
|
|
6
6
|
|
|
7
7
|
category:'RP Image',
|
|
8
8
|
color :'#DDA0DD',
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
inputs:1, outputs:1,
|
|
36
|
-
label:function(){ return this.name || "crop"; },
|
|
36
|
+
label:function(){ return this.name || "rp-crop"; },
|
|
37
37
|
|
|
38
38
|
/* ---------------- oneditprepare ---------------- */
|
|
39
39
|
oneditprepare:function(){
|
|
@@ -112,7 +112,9 @@
|
|
|
112
112
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
}
|
|
115
|
+
};
|
|
116
|
+
RED.nodes.registerType('rp-crop', _rpNodeCfg);
|
|
117
|
+
RED.nodes.registerType('crop', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
116
118
|
|
|
117
119
|
// Debug image display renderer - shared across all image processing nodes
|
|
118
120
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -225,7 +227,123 @@
|
|
|
225
227
|
</script>
|
|
226
228
|
|
|
227
229
|
<!-- 2 ▸ Edit‑dialog template -->
|
|
228
|
-
<script type="text/x-red" data-template-name="crop">
|
|
230
|
+
<script type="text/x-red" data-template-name="rp-crop">
|
|
231
|
+
|
|
232
|
+
<!-- Name -->
|
|
233
|
+
<div class="form-row">
|
|
234
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
235
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<hr>
|
|
239
|
+
|
|
240
|
+
<!-- STANDARD I/O SECTION (same as all other nodes) -->
|
|
241
|
+
<div class="form-row">
|
|
242
|
+
<label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input from</label>
|
|
243
|
+
<input type="text" id="node-input-inputPath" style="width: 70%;">
|
|
244
|
+
<input type="hidden" id="node-input-inputPathType">
|
|
245
|
+
</div>
|
|
246
|
+
<div class="form-row">
|
|
247
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
248
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
249
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
250
|
+
</div>
|
|
251
|
+
<div class="form-row">
|
|
252
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
253
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
254
|
+
<option value="raw">Raw (fastest)</option>
|
|
255
|
+
<option value="jpg">JPEG</option>
|
|
256
|
+
<option value="png">PNG</option>
|
|
257
|
+
<option value="webp">WebP</option>
|
|
258
|
+
</select>
|
|
259
|
+
</div>
|
|
260
|
+
<div class="form-row" id="quality-row">
|
|
261
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
262
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
263
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
264
|
+
</div>
|
|
265
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
266
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
267
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
268
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
269
|
+
</div>
|
|
270
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
271
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
272
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
273
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
274
|
+
</div>
|
|
275
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
276
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
277
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
278
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
279
|
+
</div>
|
|
280
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
281
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
282
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
283
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<!-- Debug Configuration -->
|
|
287
|
+
<div class="form-row">
|
|
288
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
289
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
290
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
291
|
+
</div>
|
|
292
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
293
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
294
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
295
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
296
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<hr>
|
|
300
|
+
|
|
301
|
+
<!-- CROP-SPECIFIC SECTION -->
|
|
302
|
+
<div class="form-row">
|
|
303
|
+
<label for="node-input-coordNorm"><i class="fa fa-percent"></i> Normalised</label>
|
|
304
|
+
<input type="checkbox" id="node-input-coordNorm" style="width: 20px; height: 20px;">
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<!-- Tips that toggle -->
|
|
308
|
+
<div id="norm-enabled" class="form-tips" style="font-size: 0.85em; margin: 4px 0; color: #666;">
|
|
309
|
+
<b>Normalised ON:</b> values must be between <code>0.0</code> and <code>1.0</code> (fractions of image dimensions).
|
|
310
|
+
</div>
|
|
311
|
+
<div id="norm-disabled" class="form-tips" style="font-size: 0.85em; margin: 4px 0; color: #666;">
|
|
312
|
+
<b>Normalised OFF:</b> values are absolute pixels from top-left corner.
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<div class="form-row">
|
|
316
|
+
<label for="node-input-cropX"><i class="fa fa-arrows-h"></i> X Position</label>
|
|
317
|
+
<input type="text" id="node-input-cropX" style="width: 70%;" placeholder="0">
|
|
318
|
+
<input type="hidden" id="node-input-cropXType">
|
|
319
|
+
</div>
|
|
320
|
+
<div class="form-row">
|
|
321
|
+
<label for="node-input-cropY"><i class="fa fa-arrows-v"></i> Y Position</label>
|
|
322
|
+
<input type="text" id="node-input-cropY" style="width: 70%;" placeholder="0">
|
|
323
|
+
<input type="hidden" id="node-input-cropYType">
|
|
324
|
+
</div>
|
|
325
|
+
<div class="form-row">
|
|
326
|
+
<label for="node-input-width"><i class="fa fa-arrows-h"></i> Width</label>
|
|
327
|
+
<input type="text" id="node-input-width" style="width: 70%;" placeholder="100">
|
|
328
|
+
<input type="hidden" id="node-input-widthType">
|
|
329
|
+
</div>
|
|
330
|
+
<div class="form-row">
|
|
331
|
+
<label for="node-input-height"><i class="fa fa-arrows-v"></i> Height</label>
|
|
332
|
+
<input type="text" id="node-input-height" style="width: 70%;" placeholder="100">
|
|
333
|
+
<input type="hidden" id="node-input-heightType">
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
<div class="form-tips">
|
|
337
|
+
<b>Tips:</b>
|
|
338
|
+
<ul>
|
|
339
|
+
<li><b>X, Y:</b> Position of the top-left corner of the crop area.</li>
|
|
340
|
+
<li><b>Width, Height:</b> Dimensions of the crop area.</li>
|
|
341
|
+
<li>All parameters support dynamic values from <code>msg</code>, <code>flow</code>, or <code>global</code> context.</li>
|
|
342
|
+
</ul>
|
|
343
|
+
</div>
|
|
344
|
+
</script>
|
|
345
|
+
|
|
346
|
+
<script type="text/x-red" data-template-name="crop">
|
|
229
347
|
|
|
230
348
|
<!-- Name -->
|
|
231
349
|
<div class="form-row">
|
|
@@ -342,7 +460,97 @@
|
|
|
342
460
|
</script>
|
|
343
461
|
|
|
344
462
|
<!-- 3 ▸ Help panel -->
|
|
345
|
-
<script type="text/x-red" data-help-name="crop">
|
|
463
|
+
<script type="text/x-red" data-help-name="rp-crop">
|
|
464
|
+
<p>Extracts a rectangular region from images using flexible coordinate systems and dynamic value sources.</p>
|
|
465
|
+
|
|
466
|
+
<h3>Details</h3>
|
|
467
|
+
<p>This node crops images by extracting a rectangular region defined by X, Y position and width, height dimensions. It supports both normalized coordinates (0-1 relative to image dimensions) and absolute pixel coordinates. All coordinate values can be dynamically sourced from message properties, flow, or global context.</p>
|
|
468
|
+
|
|
469
|
+
<h3>Properties</h3>
|
|
470
|
+
<dl class="message-properties">
|
|
471
|
+
<dt>Input from <span class="property-type">string</span></dt>
|
|
472
|
+
<dd>The location to read image data from. You can select between <code>msg</code>, <code>flow</code>, or <code>global</code> context. Defaults to <code>msg.payload</code>.</dd>
|
|
473
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
474
|
+
<dd>The location where the cropped image will be stored. You can select between <code>msg</code>, <code>flow</code>, or <code>global</code> context. Defaults to <code>msg.payload</code>.</dd>
|
|
475
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
476
|
+
<dd>Choose output format: <code>raw</code> (fastest, standard image object), <code>jpg</code>, <code>png</code>, or <code>webp</code> (encoded file buffers).</dd>
|
|
477
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
478
|
+
<dd>Compression quality for JPEG and WebP formats (1-100). Only visible when jpg or webp format is selected. Default: 90.</dd>
|
|
479
|
+
<dt>Normalised <span class="property-type">boolean</span></dt>
|
|
480
|
+
<dd>When enabled, coordinates are normalized (0.0-1.0 as fractions of image dimensions). When disabled, coordinates are absolute pixels.</dd>
|
|
481
|
+
<dt>X Position <span class="property-type">number|string</span></dt>
|
|
482
|
+
<dd>X coordinate of the top-left corner of the crop area. Can be fixed number or dynamic value from msg property, flow, or global context.</dd>
|
|
483
|
+
<dt>Y Position <span class="property-type">number|string</span></dt>
|
|
484
|
+
<dd>Y coordinate of the top-left corner of the crop area. Can be fixed number or dynamic value from msg property, flow, or global context.</dd>
|
|
485
|
+
<dt>Width <span class="property-type">number|string</span></dt>
|
|
486
|
+
<dd>Width of the crop area. Can be fixed number or dynamic value from msg property, flow, or global context.</dd>
|
|
487
|
+
<dt>Height <span class="property-type">number|string</span></dt>
|
|
488
|
+
<dd>Height of the crop area. Can be fixed number or dynamic value from msg property, flow, or global context.</dd>
|
|
489
|
+
</dl>
|
|
490
|
+
|
|
491
|
+
<h3>Inputs</h3>
|
|
492
|
+
<dl class="message-properties">
|
|
493
|
+
<dt>payload <span class="property-type">object | array</span></dt>
|
|
494
|
+
<dd>Single image object or array of image objects in standard format: <code>{ data: Buffer, width: number, height: number, channels: number, colorSpace: string, dtype: string }</code></dd>
|
|
495
|
+
</dl>
|
|
496
|
+
|
|
497
|
+
<h3>Outputs</h3>
|
|
498
|
+
<dl class="message-properties">
|
|
499
|
+
<dt>payload <span class="property-type">object | array | Buffer</span></dt>
|
|
500
|
+
<dd>Cropped image(s). Format depends on Output Format setting: raw image object(s) or encoded file buffer(s).</dd>
|
|
501
|
+
</dl>
|
|
502
|
+
|
|
503
|
+
<h3>Coordinate Systems</h3>
|
|
504
|
+
<p><strong>Normalized Coordinates (0.0-1.0):</strong></p>
|
|
505
|
+
<ul>
|
|
506
|
+
<li><strong>Advantages:</strong> Resolution-independent, easy to work with percentages</li>
|
|
507
|
+
<li><strong>Example:</strong> X=0.25, Y=0.25, Width=0.5, Height=0.5 crops the center quarter of any image</li>
|
|
508
|
+
<li><strong>Range:</strong> All values must be between 0.0 and 1.0</li>
|
|
509
|
+
</ul>
|
|
510
|
+
<p><strong>Absolute Pixel Coordinates:</strong></p>
|
|
511
|
+
<ul>
|
|
512
|
+
<li><strong>Advantages:</strong> Precise pixel-level control</li>
|
|
513
|
+
<li><strong>Example:</strong> X=100, Y=50, Width=200, Height=150 crops a 200x150 region starting at pixel (100,50)</li>
|
|
514
|
+
<li><strong>Range:</strong> Values are in pixels from top-left corner</li>
|
|
515
|
+
</ul>
|
|
516
|
+
|
|
517
|
+
<h3>Examples</h3>
|
|
518
|
+
<ul>
|
|
519
|
+
<li><strong>Center Crop (Normalized):</strong> X=0.25, Y=0.25, Width=0.5, Height=0.5 → Center quarter of image</li>
|
|
520
|
+
<li><strong>Top-Left Corner (Pixels):</strong> X=0, Y=0, Width=100, Height=100 → 100x100 pixel square from top-left</li>
|
|
521
|
+
<li><strong>Dynamic Crop:</strong> X=msg.cropX, Y=msg.cropY → Use coordinates from message properties</li>
|
|
522
|
+
<li><strong>Face Detection Crop:</strong> Coordinates calculated by face detection → dynamic cropping based on detected faces</li>
|
|
523
|
+
</ul>
|
|
524
|
+
|
|
525
|
+
<h3>Node Interactions</h3>
|
|
526
|
+
<p><strong>Input Sources:</strong> Image-in, Array-out, other transform nodes</p>
|
|
527
|
+
<p><strong>Output Destinations:</strong> Other transform nodes, Mix nodes (concat, mosaic), Array-in for collections</p>
|
|
528
|
+
<p><strong>Common Workflows:</strong> Face detection → Crop, Image preprocessing → Crop → Resize, Batch cropping for thumbnails</p>
|
|
529
|
+
|
|
530
|
+
<h3>Output Formats</h3>
|
|
531
|
+
<ul>
|
|
532
|
+
<li><strong>Raw:</strong> Standard image object (fastest, for further processing)</li>
|
|
533
|
+
<li><strong>JPEG:</strong> Compressed file buffer with quality setting</li>
|
|
534
|
+
<li><strong>PNG:</strong> Lossless compressed file buffer</li>
|
|
535
|
+
<li><strong>WebP:</strong> Modern compressed format with quality setting</li>
|
|
536
|
+
</ul>
|
|
537
|
+
|
|
538
|
+
<h3>Boundary Handling</h3>
|
|
539
|
+
<p>The node automatically handles boundary conditions:</p>
|
|
540
|
+
<ul>
|
|
541
|
+
<li><strong>Out-of-bounds:</strong> Crop area is clipped to image boundaries</li>
|
|
542
|
+
<li><strong>Invalid coordinates:</strong> Negative positions are clamped to 0</li>
|
|
543
|
+
<li><strong>Oversized dimensions:</strong> Width/height automatically limited to available space</li>
|
|
544
|
+
</ul>
|
|
545
|
+
|
|
546
|
+
<h3>Error Handling</h3>
|
|
547
|
+
<p>The node validates input data and coordinates, displaying warnings for invalid inputs. Invalid coordinates are clamped to valid ranges. Processing errors are logged and the message is not propagated.</p>
|
|
548
|
+
|
|
549
|
+
<h3>Performance</h3>
|
|
550
|
+
<p>Uses optimized C++ backend with OpenCV for high-performance cropping. Node status displays processing time including conversion, processing, and encoding phases. Array inputs are processed in parallel for optimal performance.</p>
|
|
551
|
+
</script>
|
|
552
|
+
|
|
553
|
+
<script type="text/x-red" data-help-name="crop">
|
|
346
554
|
<p>Extracts a rectangular region from images using flexible coordinate systems and dynamic value sources.</p>
|
|
347
555
|
|
|
348
556
|
<h3>Details</h3>
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
var _rpNodeCfg = {
|
|
84
84
|
category: 'RP Image',
|
|
85
85
|
color: '#DDA0DD',
|
|
86
86
|
defaults: {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
outputs: 1,
|
|
106
106
|
icon: "font-awesome/fa-paint-brush",
|
|
107
107
|
label: function () {
|
|
108
|
-
return this.name || "draw";
|
|
108
|
+
return this.name || "rp-draw";
|
|
109
109
|
},
|
|
110
110
|
oneditprepare: function () {
|
|
111
111
|
const node = this;
|
|
@@ -615,10 +615,118 @@
|
|
|
615
615
|
this.points = readTableValues('points');
|
|
616
616
|
this.lines = readTableValues('lines');
|
|
617
617
|
}
|
|
618
|
-
}
|
|
618
|
+
};
|
|
619
|
+
RED.nodes.registerType('rp-draw', _rpNodeCfg);
|
|
620
|
+
RED.nodes.registerType('draw', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
619
621
|
})();
|
|
620
622
|
</script>
|
|
621
623
|
|
|
624
|
+
<script type="text/x-red" data-template-name="rp-draw">
|
|
625
|
+
<!-- Name -->
|
|
626
|
+
<div class="form-row">
|
|
627
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
628
|
+
<input type="text" id="node-input-name" placeholder="draw">
|
|
629
|
+
</div>
|
|
630
|
+
|
|
631
|
+
<hr>
|
|
632
|
+
|
|
633
|
+
<!-- Standard I/O -->
|
|
634
|
+
<div class="form-row">
|
|
635
|
+
<label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input from</label>
|
|
636
|
+
<input type="text" id="node-input-inputPath" style="width: 70%;">
|
|
637
|
+
<input type="hidden" id="node-input-inputPathType">
|
|
638
|
+
</div>
|
|
639
|
+
<div class="form-row">
|
|
640
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
641
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
642
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
643
|
+
</div>
|
|
644
|
+
<div class="form-row">
|
|
645
|
+
<label for="node-input-outputFormat"><i class="fa fa-picture-o"></i> Output format</label>
|
|
646
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
647
|
+
<option value="raw">Raw (fastest)</option>
|
|
648
|
+
<option value="jpg">JPEG</option>
|
|
649
|
+
<option value="png">PNG</option>
|
|
650
|
+
<option value="webp">WebP</option>
|
|
651
|
+
</select>
|
|
652
|
+
</div>
|
|
653
|
+
<div class="form-row" id="quality-row">
|
|
654
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
655
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" style="width: 70px;">
|
|
656
|
+
<span style="margin-left: 8px; color:#666;">1-100 (JPG/WebP only)</span>
|
|
657
|
+
</div>
|
|
658
|
+
<div class="form-row" id="png-optimize-row" style="display:none;">
|
|
659
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG optimize</label>
|
|
660
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
661
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG output</label>
|
|
662
|
+
</div>
|
|
663
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
664
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
665
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
666
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
667
|
+
</div>
|
|
668
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
669
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
670
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
671
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
672
|
+
</div>
|
|
673
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
674
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
675
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
676
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
677
|
+
</div>
|
|
678
|
+
|
|
679
|
+
<!-- Debug configuration -->
|
|
680
|
+
<div class="form-row">
|
|
681
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug preview</label>
|
|
682
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
683
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
684
|
+
</div>
|
|
685
|
+
<div class="form-row" id="debug-width-row" style="display:none;">
|
|
686
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug width</label>
|
|
687
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
688
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
689
|
+
<span style="margin-left: 8px; color:#666;">pixels</span>
|
|
690
|
+
</div>
|
|
691
|
+
|
|
692
|
+
<hr>
|
|
693
|
+
|
|
694
|
+
<!-- Points configuration -->
|
|
695
|
+
<div class="form-row">
|
|
696
|
+
<label style="width:100%;"><i class="fa fa-dot-circle-o"></i> Points</label>
|
|
697
|
+
<div id="points-container" style="width:100%;"></div>
|
|
698
|
+
</div>
|
|
699
|
+
<div class="form-tips" style="font-size:0.85em; color:#666;">
|
|
700
|
+
<b>Point settings:</b>
|
|
701
|
+
<ul>
|
|
702
|
+
<li><b>X, Y</b> - normalized coordinates (0.0-1.0) from the top-left of the image.</li>
|
|
703
|
+
<li><b>Radius</b> - relative point size; larger values draw bigger dots.</li>
|
|
704
|
+
<li><b>Color</b> - pick a fixed colour or source it from the flow via the typed selector.</li>
|
|
705
|
+
<li><b>Opacity</b> - blend amount from 0 (transparent) to 1 (solid).</li>
|
|
706
|
+
<li><b>Mode</b> - switch to <em>List</em> to feed [[x,y], ...] from msg/flow/global/JSON for bulk points.</li>
|
|
707
|
+
<li>Use <b>Add point</b> and <b>Remove</b> to manage rows.</li>
|
|
708
|
+
</ul>
|
|
709
|
+
</div>
|
|
710
|
+
|
|
711
|
+
<hr>
|
|
712
|
+
|
|
713
|
+
<!-- Lines configuration -->
|
|
714
|
+
<div class="form-row">
|
|
715
|
+
<label style="width:100%;"><i class="fa fa-minus"></i> Lines</label>
|
|
716
|
+
<div id="lines-container" style="width:100%;"></div>
|
|
717
|
+
</div>
|
|
718
|
+
<div class="form-tips" style="font-size:0.85em; color:#666;">
|
|
719
|
+
<b>Line settings:</b>
|
|
720
|
+
<ul>
|
|
721
|
+
<li><b>X1/Y1 & X2/Y2</b> - start and end coordinates (normalized 0.0-1.0).</li>
|
|
722
|
+
<li><b>Thickness</b> - relative stroke width; higher values make bolder lines.</li>
|
|
723
|
+
<li><b>Color & Opacity</b> - pick a stroke colour and blend level, or reference flow data.</li>
|
|
724
|
+
<li><b>Mode</b> - switch to <em>List</em> to feed [[x0,y0,x1,y1], ...] for multiple segments.</li>
|
|
725
|
+
<li>Use <b>Add line</b> and <b>Remove</b> to maintain the list.</li>
|
|
726
|
+
</ul>
|
|
727
|
+
</div>
|
|
728
|
+
</script>
|
|
729
|
+
|
|
622
730
|
<script type="text/x-red" data-template-name="draw">
|
|
623
731
|
<!-- Name -->
|
|
624
732
|
<div class="form-row">
|
|
@@ -725,6 +833,23 @@
|
|
|
725
833
|
</div>
|
|
726
834
|
</script>
|
|
727
835
|
|
|
836
|
+
<script type="text/x-red" data-help-name="rp-draw">
|
|
837
|
+
<p><b>draw</b> overlays configurable points and line segments onto an image. The editor provides typed values for every field, plus integrated color pickers for quick selection of fixed colors.</p>
|
|
838
|
+
|
|
839
|
+
<h3>Inputs</h3>
|
|
840
|
+
<p>Accepts a single image from the configured message or context path in either Rosepetal raw format or an encoded buffer.</p>
|
|
841
|
+
|
|
842
|
+
<h3>Configuration</h3>
|
|
843
|
+
<p>Each point entry sets X/Y coordinates, point radius, color, and opacity. Each line entry defines start and end coordinates, thickness, color, and opacity. Coordinates and sizes are normalized (0-1) so they scale with any image resolution. All fields support fixed values, message properties, or flow/global context references through the typed input selector.</p>
|
|
844
|
+
<p>Switch a row to <b>List</b> mode to emit multiple shapes from one card. For points, supply <code>[[x,y], ...]</code>. For lines, supply <code>[[x0,y0,x1,y1], ...]</code>. The row's radius/thickness/color/opacity apply to every entry in the list.</p>
|
|
845
|
+
|
|
846
|
+
<h3>Output</h3>
|
|
847
|
+
<p>The annotated image is written to the selected location. Choose <code>raw</code> to retain the native Rosepetal structure or encode to JPG/PNG/WebP with quality and optimization controls.</p>
|
|
848
|
+
|
|
849
|
+
<h3>Debug</h3>
|
|
850
|
+
<p>Enable the debug preview to emit a resized image over the shared debug channel for live inspection in the editor.</p>
|
|
851
|
+
</script>
|
|
852
|
+
|
|
728
853
|
<script type="text/x-red" data-help-name="draw">
|
|
729
854
|
<p><b>draw</b> overlays configurable points and line segments onto an image. The editor provides typed values for every field, plus integrated color pickers for quick selection of fixed colors.</p>
|
|
730
855
|
|