@rosepetal/node-red-contrib-image-tools 1.2.2 → 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.
Files changed (43) hide show
  1. package/.github/workflows/build-prebuild.yml +3 -0
  2. package/install.sh +8 -0
  3. package/node-red-contrib-image-tools/lib/node-utils.js +64 -0
  4. package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +242 -3
  5. package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +10 -3
  6. package/node-red-contrib-image-tools/nodes/blend/add-mask.html +282 -4
  7. package/node-red-contrib-image-tools/nodes/blend/add-mask.js +15 -8
  8. package/node-red-contrib-image-tools/nodes/blend/add-masks.html +206 -3
  9. package/node-red-contrib-image-tools/nodes/blend/add-masks.js +10 -3
  10. package/node-red-contrib-image-tools/nodes/blend/blend.html +332 -4
  11. package/node-red-contrib-image-tools/nodes/blend/blend.js +10 -3
  12. package/node-red-contrib-image-tools/nodes/io/folder-in.html +147 -3
  13. package/node-red-contrib-image-tools/nodes/io/folder-in.js +2 -1
  14. package/node-red-contrib-image-tools/nodes/io/image-in.html +81 -2
  15. package/node-red-contrib-image-tools/nodes/io/image-in.js +2 -1
  16. package/node-red-contrib-image-tools/nodes/io/image-out.html +197 -3
  17. package/node-red-contrib-image-tools/nodes/io/image-out.js +2 -1
  18. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +398 -3
  19. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +11 -4
  20. package/node-red-contrib-image-tools/nodes/mix/concat.html +245 -5
  21. package/node-red-contrib-image-tools/nodes/mix/concat.js +10 -3
  22. package/node-red-contrib-image-tools/nodes/mix/mosaic.html +307 -3
  23. package/node-red-contrib-image-tools/nodes/mix/mosaic.js +10 -3
  24. package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +217 -4
  25. package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +11 -2
  26. package/node-red-contrib-image-tools/nodes/specialized/image-align.html +285 -4
  27. package/node-red-contrib-image-tools/nodes/specialized/image-align.js +9 -2
  28. package/node-red-contrib-image-tools/nodes/transform/color-convert.html +169 -6
  29. package/node-red-contrib-image-tools/nodes/transform/color-convert.js +11 -2
  30. package/node-red-contrib-image-tools/nodes/transform/crop.html +237 -5
  31. package/node-red-contrib-image-tools/nodes/transform/crop.js +11 -2
  32. package/node-red-contrib-image-tools/nodes/transform/draw.html +152 -3
  33. package/node-red-contrib-image-tools/nodes/transform/draw.js +10 -3
  34. package/node-red-contrib-image-tools/nodes/transform/filter.html +369 -4
  35. package/node-red-contrib-image-tools/nodes/transform/filter.js +11 -2
  36. package/node-red-contrib-image-tools/nodes/transform/padding.html +316 -5
  37. package/node-red-contrib-image-tools/nodes/transform/padding.js +11 -2
  38. package/node-red-contrib-image-tools/nodes/transform/resize.html +203 -5
  39. package/node-red-contrib-image-tools/nodes/transform/resize.js +11 -2
  40. package/node-red-contrib-image-tools/nodes/transform/rotate.html +164 -5
  41. package/node-red-contrib-image-tools/nodes/transform/rotate.js +11 -2
  42. package/package.json +71 -71
  43. package/scripts/dual-register.js +267 -0
@@ -1,5 +1,5 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('resize', {
2
+ var _rpNodeCfg = {
3
3
  category: 'RP Image',
4
4
  color: '#DDA0DD',
5
5
  defaults: {
@@ -12,6 +12,9 @@
12
12
  outputFormat: { value: "raw" },
13
13
  outputQuality: { value: 90 },
14
14
  pngOptimize: { value: false },
15
+ webpLossless: { value: false },
16
+ webpSmartSubsample: { value: false },
17
+ webpEffort: { value: "" },
15
18
  // Debug configuration
16
19
  debugEnabled: { value: false },
17
20
  debugWidth: { value: 200 },
@@ -30,7 +33,7 @@
30
33
  icon: "font-awesome/fa-arrows-alt",
31
34
  label: function() {
32
35
  if (this.name) { return this.name; }
33
- return `resize`;
36
+ return 'rp-resize';
34
37
  },
35
38
  oneditprepare: function() {
36
39
  // === Inicialización de los Widgets "TypedInput" ===
@@ -103,13 +106,19 @@
103
106
  } else {
104
107
  $('#quality-row').hide();
105
108
  }
106
-
109
+
107
110
  // Show PNG optimize checkbox only when PNG is selected
108
111
  if (format === 'png') {
109
112
  $('#png-optimize-row').show();
110
113
  } else {
111
114
  $('#png-optimize-row').hide();
112
115
  }
116
+
117
+ // Show WebP advanced options only when WebP is selected
118
+ const isWebp = format === 'webp';
119
+ $('#webp-lossless-row').toggle(isWebp);
120
+ $('#webp-smartsubsample-row').toggle(isWebp);
121
+ $('#webp-effort-row').toggle(isWebp);
113
122
  }
114
123
 
115
124
  $('#node-input-outputFormat').on('change', updateQualityVisibility);
@@ -146,7 +155,9 @@
146
155
  $('#node-input-debugEnabled').data('debug-enabled', enabled);
147
156
  });
148
157
  }
149
- });
158
+ };
159
+ RED.nodes.registerType('rp-resize', _rpNodeCfg);
160
+ RED.nodes.registerType('resize', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
150
161
 
151
162
  // Debug image display renderer - shared across all image processing nodes
152
163
  if (!window.debugImageRendererInitialized) {
@@ -271,7 +282,7 @@
271
282
  }
272
283
  </script>
273
284
 
274
- <script type="text/x-red" data-template-name="resize">
285
+ <script type="text/x-red" data-template-name="rp-resize">
275
286
  <div class="form-row">
276
287
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
277
288
  <input type="text" id="node-input-name" placeholder="Name">
@@ -309,7 +320,119 @@
309
320
  <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
310
321
  <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
311
322
  </div>
323
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
324
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
325
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
326
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
327
+ </div>
328
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
329
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
330
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
331
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
332
+ </div>
333
+ <div class="form-row" id="webp-effort-row" style="display: none;">
334
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
335
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
336
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
337
+ </div>
338
+
339
+ <!-- Debug Configuration -->
340
+ <div class="form-row">
341
+ <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
342
+ <input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
343
+ <label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
344
+ </div>
345
+ <div class="form-row" id="debug-width-row" style="display: none;">
346
+ <label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
347
+ <input type="text" id="node-input-debugWidth" style="width: 120px;">
348
+ <input type="hidden" id="node-input-debugWidthType">
349
+ <span style="margin-left: 10px; color: #666;">pixels</span>
350
+ </div>
312
351
 
352
+ <hr>
353
+
354
+ <div class="form-row">
355
+ <label><i class="fa fa-arrows-h"></i> Width</label>
356
+ <div style="display: flex; align-items: center; width: 70%;">
357
+ <select id="node-input-widthMode" style="width: 120px; margin-right: 5px;">
358
+ <option value="set">Set to</option>
359
+ <option value="multiply">Multiply by</option>
360
+ </select>
361
+ <input type="text" id="node-input-widthValue" style="flex-grow: 1;">
362
+ <input type="hidden" id="node-input-widthType">
363
+ </div>
364
+ </div>
365
+ <div class="form-row">
366
+ <label><i class="fa fa-arrows-v"></i> Height</label>
367
+ <div style="display: flex; align-items: center; width: 70%;">
368
+ <select id="node-input-heightMode" style="width: 120px; margin-right: 5px;">
369
+ <option value="set">Set to</option>
370
+ <option value="multiply">Multiply by</option>
371
+ </select>
372
+ <input type="text" id="node-input-heightValue" style="flex-grow: 1;">
373
+ <input type="hidden" id="node-input-heightType">
374
+ </div>
375
+ </div>
376
+
377
+ <div class="form-tips">
378
+ <b>Tip:</b> If a dimension value is left empty, it will be set to 'Auto' to maintain the original aspect ratio.
379
+ </div>
380
+ </script>
381
+
382
+ <script type="text/x-red" data-template-name="resize">
383
+ <div class="form-row">
384
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
385
+ <input type="text" id="node-input-name" placeholder="Name">
386
+ </div>
387
+
388
+ <hr>
389
+
390
+ <div class="form-row">
391
+ <label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input from</label>
392
+ <input type="text" id="node-input-inputPath" style="width: 70%;">
393
+ <input type="hidden" id="node-input-inputPathType">
394
+ </div>
395
+ <div class="form-row">
396
+ <label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
397
+ <input type="text" id="node-input-outputPath" style="width: 70%;">
398
+ <input type="hidden" id="node-input-outputPathType">
399
+
400
+ </div>
401
+ <div class="form-row">
402
+ <label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
403
+ <select id="node-input-outputFormat" style="width: 200px;">
404
+ <option value="raw">Raw (fastest)</option>
405
+ <option value="jpg">JPEG</option>
406
+ <option value="png">PNG</option>
407
+ <option value="webp">WebP</option>
408
+ </select>
409
+ </div>
410
+ <div class="form-row" id="quality-row">
411
+ <label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
412
+ <input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
413
+ <span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
414
+ </div>
415
+ <div class="form-row" id="png-optimize-row" style="display: none;">
416
+ <label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
417
+ <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
418
+ <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
419
+ </div>
420
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
421
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
422
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
423
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
424
+ </div>
425
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
426
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
427
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
428
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
429
+ </div>
430
+ <div class="form-row" id="webp-effort-row" style="display: none;">
431
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
432
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
433
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
434
+ </div>
435
+
313
436
  <!-- Debug Configuration -->
314
437
  <div class="form-row">
315
438
  <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
@@ -353,6 +476,81 @@
353
476
  </div>
354
477
  </script>
355
478
 
479
+ <script type="text/x-red" data-help-name="rp-resize">
480
+ <p>Resizes images to specified dimensions using high-performance C++ processing with OpenCV backend.</p>
481
+
482
+ <h3>Details</h3>
483
+ <p>This node provides flexible image resizing capabilities with multiple operation modes and dynamic value sources. It supports both single images and arrays, with automatic aspect ratio preservation when one dimension is omitted. All processing is performed asynchronously using the optimized C++ backend.</p>
484
+
485
+ <h3>Properties</h3>
486
+ <dl class="message-properties">
487
+ <dt>Input from <span class="property-type">string</span></dt>
488
+ <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>
489
+ <dt>Output to <span class="property-type">string</span></dt>
490
+ <dd>The location where the resized 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>
491
+ <dt>Output Format <span class="property-type">string</span></dt>
492
+ <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>
493
+ <dt>Quality <span class="property-type">number</span></dt>
494
+ <dd>Compression quality for JPEG and WebP formats (1-100). Only visible when jpg or webp format is selected. Default: 90.</dd>
495
+ <dt>Width Mode <span class="property-type">string</span></dt>
496
+ <dd>Width operation: <code>Set to</code> (fixed pixel value) or <code>Multiply by</code> (scale factor).</dd>
497
+ <dt>Width Value <span class="property-type">number|string</span></dt>
498
+ <dd>Width value from number, msg property, flow, or global context. Leave empty for automatic aspect ratio preservation.</dd>
499
+ <dt>Height Mode <span class="property-type">string</span></dt>
500
+ <dd>Height operation: <code>Set to</code> (fixed pixel value) or <code>Multiply by</code> (scale factor).</dd>
501
+ <dt>Height Value <span class="property-type">number|string</span></dt>
502
+ <dd>Height value from number, msg property, flow, or global context. Leave empty for automatic aspect ratio preservation.</dd>
503
+ </dl>
504
+
505
+ <h3>Inputs</h3>
506
+ <dl class="message-properties">
507
+ <dt>payload <span class="property-type">object | array</span></dt>
508
+ <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>
509
+ </dl>
510
+
511
+ <h3>Outputs</h3>
512
+ <dl class="message-properties">
513
+ <dt>payload <span class="property-type">object | array | Buffer</span></dt>
514
+ <dd>Resized image(s). Format depends on Output Format setting: raw image object(s) or encoded file buffer(s).</dd>
515
+ </dl>
516
+
517
+ <h3>Dimension Configuration</h3>
518
+ <p><strong>Operation Modes:</strong></p>
519
+ <ul>
520
+ <li><strong>Set to:</strong> Resizes the dimension to a fixed pixel value (e.g., 800 pixels)</li>
521
+ <li><strong>Multiply by:</strong> Multiplies the original dimension by a factor (e.g., 0.5 for half size, 2.0 for double size)</li>
522
+ </ul>
523
+ <p><strong>Value Sources:</strong> Values can come from fixed numbers, message properties, flow context, or global context using the TypedInput dropdowns.</p>
524
+ <p><strong>Aspect Ratio:</strong> If either width or height is left empty, it will be calculated automatically to maintain the original aspect ratio.</p>
525
+
526
+ <h3>Examples</h3>
527
+ <ul>
528
+ <li><strong>Fixed Size:</strong> Width: Set to 800, Height: Set to 600 → All images resized to 800x600</li>
529
+ <li><strong>Proportional:</strong> Width: Set to 800, Height: (empty) → Width set to 800, height calculated proportionally</li>
530
+ <li><strong>Scale Factor:</strong> Width: Multiply by 0.5, Height: Multiply by 0.5 → Images scaled to half size</li>
531
+ <li><strong>Dynamic Values:</strong> Width: Set to msg.targetWidth → Use width value from message property</li>
532
+ </ul>
533
+
534
+ <h3>Node Interactions</h3>
535
+ <p><strong>Input Sources:</strong> Image-in, Array-out, other transform nodes</p>
536
+ <p><strong>Output Destinations:</strong> Other transform nodes, Mix nodes (concat, mosaic), Array-in for collections</p>
537
+ <p><strong>Common Workflows:</strong> Image-in → Resize → other transforms, Array processing → Resize → Array-select</p>
538
+
539
+ <h3>Output Formats</h3>
540
+ <ul>
541
+ <li><strong>Raw:</strong> Standard image object (fastest, for further processing)</li>
542
+ <li><strong>JPEG:</strong> Compressed file buffer with quality setting</li>
543
+ <li><strong>PNG:</strong> Lossless compressed file buffer</li>
544
+ <li><strong>WebP:</strong> Modern compressed format with quality setting</li>
545
+ </ul>
546
+
547
+ <h3>Error Handling</h3>
548
+ <p>The node validates input data and dimensions, displaying warnings for invalid inputs. Processing errors are logged and the message is not propagated.</p>
549
+
550
+ <h3>Performance</h3>
551
+ <p>Uses optimized C++ backend with OpenCV for high-performance processing. Node status displays processing time. Array inputs are processed in parallel for optimal performance.</p>
552
+ </script>
553
+
356
554
  <script type="text/x-red" data-help-name="resize">
357
555
  <p>Resizes images to specified dimensions using high-performance C++ processing with OpenCV backend.</p>
358
556
 
@@ -44,6 +44,8 @@ module.exports = function (RED) {
44
44
  const outputFormat = config.outputFormat || 'raw';
45
45
  const outputQuality = parseInt(config.outputQuality) || 90;
46
46
  const pngOptimize = config.pngOptimize || false;
47
+ const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
48
+ const cppFormat = useSharpWebp ? 'raw' : outputFormat;
47
49
  const inputList = Array.isArray(originalPayload)
48
50
  ? originalPayload
49
51
  : [originalPayload];
@@ -93,7 +95,7 @@ module.exports = function (RED) {
93
95
  inputImage,
94
96
  config.widthMode, wVal,
95
97
  config.heightMode, hVal,
96
- outputFormat,
98
+ cppFormat,
97
99
  outputQuality,
98
100
  pngOptimize
99
101
  )
@@ -113,6 +115,12 @@ module.exports = function (RED) {
113
115
  { totalConvertMs: 0, totalTaskMs: 0, encodeMs: 0, images: [] }
114
116
  );
115
117
 
118
+ if (useSharpWebp) {
119
+ for (let i = 0; i < images.length; i++) {
120
+ images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
121
+ }
122
+ }
123
+
116
124
  const out = Array.isArray(originalPayload) ? images : images[0];
117
125
  const elapsedTime = performance.now() - startTime;
118
126
 
@@ -183,5 +191,6 @@ module.exports = function (RED) {
183
191
  });
184
192
  }
185
193
 
186
- RED.nodes.registerType('resize', ResizeNode);
194
+ RED.nodes.registerType('rp-resize', ResizeNode);
195
+ RED.nodes.registerType('resize', ResizeNode); // legacy compat
187
196
  };
@@ -1,5 +1,5 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('rotate', {
2
+ var _rpNodeCfg = {
3
3
  category : 'RP Image',
4
4
  color : '#DDA0DD',
5
5
  defaults : {
@@ -11,6 +11,9 @@
11
11
  outputFormat : { value:"raw" },
12
12
  outputQuality : { value:90 },
13
13
  pngOptimize : { value:false },
14
+ webpLossless : { value:false },
15
+ webpSmartSubsample : { value:false },
16
+ webpEffort : { value:"" },
14
17
  // Debug configuration
15
18
  debugEnabled : { value:false },
16
19
  debugWidth : { value:200 },
@@ -21,7 +24,7 @@
21
24
  },
22
25
  inputs :1, outputs:1,
23
26
  icon:"font-awesome/fa-rotate-right",
24
- label:function(){ return this.name || "rotate"; },
27
+ label:function(){ return this.name || "rp-rotate"; },
25
28
 
26
29
  oneditprepare:function(){
27
30
  $("#node-input-inputPath").typedInput({default:'msg',types:['msg','flow','global'],typeField:"#node-input-inputPathType"});
@@ -32,6 +35,12 @@
32
35
  const format = $("#node-input-outputFormat").val();
33
36
  $("#quality-row").toggle(format === "jpg" || format === "webp");
34
37
  $("#png-optimize-row").toggle(format === "png");
38
+
39
+ // Show WebP advanced options only when WebP is selected
40
+ const isWebp = format === "webp";
41
+ $("#webp-lossless-row").toggle(isWebp);
42
+ $("#webp-smartsubsample-row").toggle(isWebp);
43
+ $("#webp-effort-row").toggle(isWebp);
35
44
  }
36
45
  $("#node-input-outputFormat").on("change", updateQualityVisibility);
37
46
  updateQualityVisibility(); // initial state
@@ -67,7 +76,9 @@
67
76
  $('#node-input-debugEnabled').data('debug-enabled', enabled);
68
77
  });
69
78
  }
70
- });
79
+ };
80
+ RED.nodes.registerType('rp-rotate', _rpNodeCfg);
81
+ RED.nodes.registerType('rotate', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
71
82
 
72
83
  // Debug image display renderer - shared across all image processing nodes
73
84
  if (!window.debugImageRendererInitialized) {
@@ -179,7 +190,7 @@
179
190
  }
180
191
  </script>
181
192
 
182
- <script type="text/x-red" data-template-name="rotate">
193
+ <script type="text/x-red" data-template-name="rp-rotate">
183
194
  <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>
184
195
  <hr>
185
196
  <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>
@@ -203,7 +214,80 @@
203
214
  <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
204
215
  <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
205
216
  </div>
217
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
218
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
219
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
220
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
221
+ </div>
222
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
223
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
224
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
225
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
226
+ </div>
227
+ <div class="form-row" id="webp-effort-row" style="display: none;">
228
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
229
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
230
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
231
+ </div>
232
+
233
+ <!-- Debug Configuration -->
234
+ <div class="form-row">
235
+ <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
236
+ <input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
237
+ <label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
238
+ </div>
239
+ <div class="form-row" id="debug-width-row" style="display: none;">
240
+ <label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
241
+ <input type="text" id="node-input-debugWidth" style="width: 120px;">
242
+ <input type="hidden" id="node-input-debugWidthType">
243
+ <span style="margin-left: 10px; color: #666;">pixels</span>
244
+ </div>
206
245
 
246
+ <hr>
247
+ <div class="form-row"><label for="node-input-angleValue"><i class="fa fa-refresh"></i> Angle (°)</label><input type="text" id="node-input-angleValue" style="width:70%;"><input type="hidden" id="node-input-angleType"></div>
248
+ <div class="form-row"><label for="node-input-padColor"><i class="fa fa-tint"></i> Pad colour</label><input type="color" id="node-input-padColor" style="width:80px;"></div>
249
+ </script>
250
+
251
+ <script type="text/x-red" data-template-name="rotate">
252
+ <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>
253
+ <hr>
254
+ <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>
255
+ <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>
256
+ <div class="form-row">
257
+ <label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
258
+ <select id="node-input-outputFormat" style="width: 200px;">
259
+ <option value="raw">Raw (fastest)</option>
260
+ <option value="jpg">JPEG</option>
261
+ <option value="png">PNG</option>
262
+ <option value="webp">WebP</option>
263
+ </select>
264
+ </div>
265
+ <div class="form-row" id="quality-row">
266
+ <label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
267
+ <input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
268
+ <span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
269
+ </div>
270
+ <div class="form-row" id="png-optimize-row" style="display: none;">
271
+ <label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
272
+ <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
273
+ <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
274
+ </div>
275
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
276
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
277
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
278
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
279
+ </div>
280
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
281
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
282
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
283
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
284
+ </div>
285
+ <div class="form-row" id="webp-effort-row" style="display: none;">
286
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
287
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
288
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
289
+ </div>
290
+
207
291
  <!-- Debug Configuration -->
208
292
  <div class="form-row">
209
293
  <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
@@ -222,7 +306,82 @@
222
306
  <div class="form-row"><label for="node-input-padColor"><i class="fa fa-tint"></i> Pad colour</label><input type="color" id="node-input-padColor" style="width:80px;"></div>
223
307
  </script>
224
308
 
225
- <script type="text/x-red" data-help-name="rotate">
309
+ <script type="text/x-red" data-help-name="rp-rotate">
310
+ <p>Rotates images by a specified angle with customizable padding color using high-performance C++ processing.</p>
311
+
312
+ <h3>Details</h3>
313
+ <p>This node rotates images counter-clockwise by a specified angle in degrees. When rotation creates areas outside the original image bounds, these areas are filled with the specified padding color. The rotation operation supports both single images and arrays, with dynamic angle values from various sources.</p>
314
+
315
+ <h3>Properties</h3>
316
+ <dl class="message-properties">
317
+ <dt>Input from <span class="property-type">string</span></dt>
318
+ <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>
319
+ <dt>Output to <span class="property-type">string</span></dt>
320
+ <dd>The location where the rotated 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>
321
+ <dt>Output Format <span class="property-type">string</span></dt>
322
+ <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>
323
+ <dt>Quality <span class="property-type">number</span></dt>
324
+ <dd>Compression quality for JPEG and WebP formats (1-100). Only visible when jpg or webp format is selected. Default: 90.</dd>
325
+ <dt>Angle <span class="property-type">number|string</span></dt>
326
+ <dd>Rotation angle in degrees (counter-clockwise). Can be a fixed number or dynamic value from msg property, flow, or global context. Supports decimal values.</dd>
327
+ <dt>Pad Color <span class="property-type">string</span></dt>
328
+ <dd>Color to fill areas created by rotation, specified as hexadecimal color (#RRGGBB). Default: #000000 (black).</dd>
329
+ </dl>
330
+
331
+ <h3>Inputs</h3>
332
+ <dl class="message-properties">
333
+ <dt>payload <span class="property-type">object | array</span></dt>
334
+ <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>
335
+ </dl>
336
+
337
+ <h3>Outputs</h3>
338
+ <dl class="message-properties">
339
+ <dt>payload <span class="property-type">object | array | Buffer</span></dt>
340
+ <dd>Rotated image(s). Format depends on Output Format setting: raw image object(s) or encoded file buffer(s).</dd>
341
+ </dl>
342
+
343
+ <h3>Rotation Behavior</h3>
344
+ <ul>
345
+ <li><strong>Direction:</strong> Counter-clockwise rotation (positive angles)</li>
346
+ <li><strong>Angle Range:</strong> Any angle supported (0-360° and beyond)</li>
347
+ <li><strong>Padding:</strong> Areas outside original bounds filled with specified color</li>
348
+ <li><strong>Precision:</strong> Decimal angles supported (e.g., 45.5°, 30.25°)</li>
349
+ <li><strong>Canvas Size:</strong> Output canvas automatically sized to contain rotated image</li>
350
+ </ul>
351
+
352
+ <h3>Examples</h3>
353
+ <ul>
354
+ <li><strong>90° Rotation:</strong> Angle: 90 → Image rotated 90° counter-clockwise</li>
355
+ <li><strong>Custom Angle:</strong> Angle: 45.5 → Image rotated 45.5° counter-clockwise</li>
356
+ <li><strong>Dynamic Angle:</strong> Angle: msg.rotationAngle → Use angle from message property</li>
357
+ <li><strong>White Padding:</strong> Pad Color: #FFFFFF → White background for rotated areas</li>
358
+ <li><strong>Transparent Padding:</strong> For RGBA images, use appropriate color with alpha channel</li>
359
+ </ul>
360
+
361
+ <h3>Node Interactions</h3>
362
+ <p><strong>Input Sources:</strong> Image-in, Array-out, other transform nodes</p>
363
+ <p><strong>Output Destinations:</strong> Other transform nodes, Mix nodes (concat, mosaic), Array-in for collections</p>
364
+ <p><strong>Common Workflows:</strong> Image correction, artistic effects, batch rotation for image alignment</p>
365
+
366
+ <h3>Output Formats</h3>
367
+ <ul>
368
+ <li><strong>Raw:</strong> Standard image object (fastest, for further processing)</li>
369
+ <li><strong>JPEG:</strong> Compressed file buffer with quality setting</li>
370
+ <li><strong>PNG:</strong> Lossless compressed file buffer</li>
371
+ <li><strong>WebP:</strong> Modern compressed format with quality setting</li>
372
+ </ul>
373
+
374
+ <h3>Color Format</h3>
375
+ <p>Pad color is specified as hexadecimal (#RRGGBB) and passed directly to the C++ engine. The color picker provides an easy way to select colors visually.</p>
376
+
377
+ <h3>Error Handling</h3>
378
+ <p>The node validates input data and angle values, displaying warnings for invalid inputs. Invalid angles default to 0°. Processing errors are logged and the message is not propagated.</p>
379
+
380
+ <h3>Performance</h3>
381
+ <p>Uses optimized C++ backend with OpenCV for high-performance rotation processing. Node status displays processing time. Array inputs are processed in parallel for optimal performance.</p>
382
+ </script>
383
+
384
+ <script type="text/x-red" data-help-name="rotate">
226
385
  <p>Rotates images by a specified angle with customizable padding color using high-performance C++ processing.</p>
227
386
 
228
387
  <h3>Details</h3>
@@ -42,6 +42,8 @@ module.exports = function (RED) {
42
42
  const outputFormat = config.outputFormat || 'raw';
43
43
  const outputQuality = parseInt(config.outputQuality) || 90;
44
44
  const pngOptimize = config.pngOptimize || false;
45
+ const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
46
+ const cppFormat = useSharpWebp ? 'raw' : outputFormat;
45
47
  const padColorHex = config.padColor || '#000000';
46
48
 
47
49
  // Validate input images with error passthrough
@@ -69,7 +71,7 @@ module.exports = function (RED) {
69
71
 
70
72
  /* ——— lanzar rotaciones en paralelo ——— */
71
73
  const promises = imgs.map(img =>
72
- CppProcessor.rotate(img, angle, padColorHex, outputFormat, outputQuality, pngOptimize)
74
+ CppProcessor.rotate(img, angle, padColorHex, cppFormat, outputQuality, pngOptimize)
73
75
  );
74
76
 
75
77
  const results = await Promise.all(promises);
@@ -84,6 +86,12 @@ module.exports = function (RED) {
84
86
  return acc;
85
87
  }, { totalConvertMs: 0, totalTaskMs: 0, encodeMs: 0, images: [] });
86
88
 
89
+ if (useSharpWebp) {
90
+ for (let i = 0; i < images.length; i++) {
91
+ images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
92
+ }
93
+ }
94
+
87
95
  const out = Array.isArray(originalPayload) ? images : images[0];
88
96
  const durMs = performance.now() - t0;
89
97
 
@@ -157,5 +165,6 @@ module.exports = function (RED) {
157
165
  });
158
166
  }
159
167
 
160
- RED.nodes.registerType('rotate', RotateNode);
168
+ RED.nodes.registerType('rp-rotate', RotateNode);
169
+ RED.nodes.registerType('rotate', RotateNode); // legacy compat
161
170
  };