@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,6 +1,6 @@
1
1
  <!-- 1 ▸ Runtime registration ------------------------------------------------>
2
2
  <script type="text/javascript">
3
- RED.nodes.registerType('padding', {
3
+ var _rpNodeCfg = {
4
4
  category : 'RP Image',
5
5
  color : '#DDA0DD',
6
6
  icon : 'font-awesome/fa-square-o',
@@ -13,6 +13,9 @@
13
13
  outputFormat:{value:"raw"},
14
14
  outputQuality:{value:90},
15
15
  pngOptimize:{value:false},
16
+ webpLossless:{value:false},
17
+ webpSmartSubsample:{value:false},
18
+ webpEffort:{value:""},
16
19
  // Debug configuration
17
20
  debugEnabled:{value:false},
18
21
  debugWidth:{value:200},
@@ -28,7 +31,7 @@
28
31
  padColor:{value:"#000000"}
29
32
  },
30
33
  inputs:1, outputs:1,
31
- label:function(){ return this.name || "padding"; },
34
+ label:function(){ return this.name || "rp-padding"; },
32
35
 
33
36
  oneditprepare:function(){
34
37
  /* I/O path typed‑inputs */
@@ -54,6 +57,12 @@
54
57
  const format = $("#node-input-outputFormat").val();
55
58
  $("#quality-row").toggle(format === "jpg" || format === "webp");
56
59
  $("#png-optimize-row").toggle(format === "png");
60
+
61
+ // Show WebP advanced options only when WebP is selected
62
+ const isWebp = format === "webp";
63
+ $("#webp-lossless-row").toggle(isWebp);
64
+ $("#webp-smartsubsample-row").toggle(isWebp);
65
+ $("#webp-effort-row").toggle(isWebp);
57
66
  }
58
67
  $("#node-input-outputFormat").on("change", updateQualityVisibility);
59
68
  updateQualityVisibility(); // initial state
@@ -89,7 +98,9 @@
89
98
  $('#node-input-debugEnabled').data('debug-enabled', enabled);
90
99
  });
91
100
  }
92
- });
101
+ };
102
+ RED.nodes.registerType('rp-padding', _rpNodeCfg);
103
+ RED.nodes.registerType('padding', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
93
104
 
94
105
  // Debug image display renderer - shared across all image processing nodes
95
106
  if (!window.debugImageRendererInitialized) {
@@ -202,7 +213,7 @@
202
213
  </script>
203
214
 
204
215
  <!-- 2 ▸ Edit‑dialog template ------------------------------------------------>
205
- <script type="text/x-red" data-template-name="padding">
216
+ <script type="text/x-red" data-template-name="rp-padding">
206
217
  <div class="form-row">
207
218
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
208
219
  <input type="text" id="node-input-name">
@@ -239,7 +250,118 @@
239
250
  <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
240
251
  <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
241
252
  </div>
253
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
254
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
255
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
256
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
257
+ </div>
258
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
259
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
260
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
261
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
262
+ </div>
263
+ <div class="form-row" id="webp-effort-row" style="display: none;">
264
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
265
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
266
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
267
+ </div>
268
+
269
+ <!-- Debug Configuration -->
270
+ <div class="form-row">
271
+ <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
272
+ <input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
273
+ <label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
274
+ </div>
275
+ <div class="form-row" id="debug-width-row" style="display: none;">
276
+ <label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
277
+ <input type="text" id="node-input-debugWidth" style="width: 120px;">
278
+ <input type="hidden" id="node-input-debugWidthType">
279
+ <span style="margin-left: 10px; color: #666;">pixels</span>
280
+ </div>
242
281
 
282
+ <hr>
283
+
284
+ <strong>Margins (pixels)</strong>
285
+ <div class="form-row">
286
+ <label>Top</label>
287
+ <input type="text" id="node-input-top" style="width:65%;">
288
+ <input type="hidden" id="node-input-topType">
289
+ </div>
290
+ <div class="form-row">
291
+ <label>Bottom</label>
292
+ <input type="text" id="node-input-bottom" style="width:65%;">
293
+ <input type="hidden" id="node-input-bottomType">
294
+ </div>
295
+ <div class="form-row">
296
+ <label>Left</label>
297
+ <input type="text" id="node-input-left" style="width:65%;">
298
+ <input type="hidden" id="node-input-leftType">
299
+ </div>
300
+ <div class="form-row">
301
+ <label>Right</label>
302
+ <input type="text" id="node-input-right" style="width:65%;">
303
+ <input type="hidden" id="node-input-rightType">
304
+ </div>
305
+
306
+ <div class="form-row">
307
+ <label for="node-input-padColor"><i class="fa fa-tint"></i> Colour</label>
308
+ <input type="color" id="node-input-padColor" style="width:80px;">
309
+ </div>
310
+ </script>
311
+
312
+ <script type="text/x-red" data-template-name="padding">
313
+ <div class="form-row">
314
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
315
+ <input type="text" id="node-input-name">
316
+ </div>
317
+
318
+ <hr>
319
+
320
+ <div class="form-row">
321
+ <label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input</label>
322
+ <input type="text" id="node-input-inputPath" style="width:70%;">
323
+ <input type="hidden" id="node-input-inputPathType">
324
+ </div>
325
+ <div class="form-row">
326
+ <label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output</label>
327
+ <input type="text" id="node-input-outputPath" style="width:70%;">
328
+ <input type="hidden" id="node-input-outputPathType">
329
+ </div>
330
+ <div class="form-row">
331
+ <label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
332
+ <select id="node-input-outputFormat" style="width: 200px;">
333
+ <option value="raw">Raw (fastest)</option>
334
+ <option value="jpg">JPEG</option>
335
+ <option value="png">PNG</option>
336
+ <option value="webp">WebP</option>
337
+ </select>
338
+ </div>
339
+ <div class="form-row" id="quality-row">
340
+ <label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
341
+ <input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
342
+ <span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
343
+ </div>
344
+ <div class="form-row" id="png-optimize-row" style="display: none;">
345
+ <label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
346
+ <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
347
+ <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
348
+ </div>
349
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
350
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
351
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
352
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
353
+ </div>
354
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
355
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
356
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
357
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
358
+ </div>
359
+ <div class="form-row" id="webp-effort-row" style="display: none;">
360
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
361
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
362
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
363
+ </div>
364
+
243
365
  <!-- Debug Configuration -->
244
366
  <div class="form-row">
245
367
  <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
@@ -284,7 +406,196 @@
284
406
  </script>
285
407
 
286
408
  <!-- 3 ▸ Help panel --------------------------------------------------------->
287
- <script type="text/x-red" data-help-name="padding">
409
+ <script type="text/x-red" data-help-name="rp-padding">
410
+ <p>The <strong>padding</strong> node adds solid color borders around images with pixel-perfect precision. It supports independent margin control for each side and works with both single images and arrays, using high-performance C++ backend processing with OpenCV.</p>
411
+
412
+ <h3>Details</h3>
413
+ <p>This node extends images by adding colored pixels around their edges, effectively increasing the canvas size. The padding operation preserves the original image content while adding configurable margins on all sides. The node maintains the original image's color space and data type while seamlessly integrating the padding color.</p>
414
+
415
+ <h3>Properties</h3>
416
+ <dl class="message-properties">
417
+ <dt>Name <span class="property-type">string</span></dt>
418
+ <dd>Optional display name for the node</dd>
419
+
420
+ <dt>Input from <span class="property-type">msg | flow | global</span></dt>
421
+ <dd>Source path for image data (default: <code>msg.payload</code>)</dd>
422
+
423
+ <dt>Output to <span class="property-type">msg | flow | global</span></dt>
424
+ <dd>Destination path for processed image (default: <code>msg.payload</code>)</dd>
425
+
426
+ <dt>Output Format <span class="property-type">string</span></dt>
427
+ <dd>Image output format: <code>raw</code>, <code>jpg</code>, <code>png</code>, or <code>webp</code></dd>
428
+
429
+ <dt>Quality <span class="property-type">number</span></dt>
430
+ <dd>Compression quality 1-100 for JPEG and WebP formats</dd>
431
+
432
+ <dt>Top <span class="property-type">number | msg | flow | global</span></dt>
433
+ <dd>Pixels to add above the image (default: 0)</dd>
434
+
435
+ <dt>Bottom <span class="property-type">number | msg | flow | global</span></dt>
436
+ <dd>Pixels to add below the image (default: 0)</dd>
437
+
438
+ <dt>Left <span class="property-type">number | msg | flow | global</span></dt>
439
+ <dd>Pixels to add to the left of the image (default: 0)</dd>
440
+
441
+ <dt>Right <span class="property-type">number | msg | flow | global</span></dt>
442
+ <dd>Pixels to add to the right of the image (default: 0)</dd>
443
+
444
+ <dt>Colour <span class="property-type">color</span></dt>
445
+ <dd>Hex color code for padding areas (default: #000000)</dd>
446
+ </dl>
447
+
448
+ <h3>Inputs</h3>
449
+ <dl class="message-properties">
450
+ <dt>payload <span class="property-type">object | array</span></dt>
451
+ <dd>Image object(s) in standard format:
452
+ <pre>{
453
+ data: Buffer, // Raw pixel data or file buffer
454
+ width: number, // Image width in pixels
455
+ height: number, // Image height in pixels
456
+ channels: number, // Channel count (1, 3, 4)
457
+ colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
458
+ dtype: string // "uint8", "uint16", "float32"
459
+ }</pre>
460
+ </dd>
461
+ <dt>margin values <span class="property-type">number</span></dt>
462
+ <dd>When margin parameters use dynamic sources, values are read from specified paths</dd>
463
+ </dl>
464
+
465
+ <h3>Outputs</h3>
466
+ <dl class="message-properties">
467
+ <dt>payload <span class="property-type">object | array | Buffer</span></dt>
468
+ <dd>Processed image(s) with padding applied. Format depends on Output Format setting</dd>
469
+
470
+ <dt>Raw format output</dt>
471
+ <dd>Image object with updated dimensions:
472
+ <pre>{
473
+ data: Buffer, // Padded image data
474
+ width: number, // Original width + left + right
475
+ height: number, // Original height + top + bottom
476
+ channels: number, // Unchanged from input
477
+ colorSpace: string, // Unchanged from input
478
+ dtype: string // Unchanged from input
479
+ }</pre>
480
+ </dd>
481
+
482
+ <dt>Encoded format output</dt>
483
+ <dd>Compressed image buffer (JPEG/PNG/WebP) ready for storage or transmission</dd>
484
+ </dl>
485
+
486
+ <h3>Padding Behavior</h3>
487
+ <h4>Dimension Calculation</h4>
488
+ <ul>
489
+ <li><strong>New Width:</strong> original_width + left + right</li>
490
+ <li><strong>New Height:</strong> original_height + top + bottom</li>
491
+ <li><strong>Minimum Values:</strong> All margin values must be ≥ 0</li>
492
+ <li><strong>Zero Padding:</strong> When all margins are 0, returns original image unchanged</li>
493
+ </ul>
494
+
495
+ <h4>Color Handling</h4>
496
+ <ul>
497
+ <li><strong>Color Format:</strong> Input as hex color (#RRGGBB)</li>
498
+ <li><strong>Channel Mapping:</strong> Automatically converts to image's color space</li>
499
+ <li><strong>Grayscale Images:</strong> Uses luminance value of selected color</li>
500
+ <li><strong>Alpha Channels:</strong> Padding areas receive full opacity (255)</li>
501
+ </ul>
502
+
503
+ <h4>Data Type Preservation</h4>
504
+ <ul>
505
+ <li><strong>uint8:</strong> Color values scaled to 0-255 range</li>
506
+ <li><strong>uint16:</strong> Color values scaled to 0-65535 range</li>
507
+ <li><strong>float32:</strong> Color values normalized to 0.0-1.0 range</li>
508
+ </ul>
509
+
510
+ <h3>Examples</h3>
511
+ <h4>Basic Uniform Padding</h4>
512
+ <pre>// Add 10 pixels of black padding on all sides
513
+ {
514
+ top: 10, bottom: 10, left: 10, right: 10,
515
+ padColor: "#000000"
516
+ }</pre>
517
+
518
+ <h4>Asymmetric Padding</h4>
519
+ <pre>// Create letterbox effect with white top/bottom bars
520
+ {
521
+ top: 50, bottom: 50, left: 0, right: 0,
522
+ padColor: "#FFFFFF"
523
+ }</pre>
524
+
525
+ <h4>Dynamic Margins</h4>
526
+ <pre>// Use message properties for responsive padding
527
+ msg.topPadding = 20;
528
+ msg.sidePadding = 15;
529
+ // Configure node: top from msg.topPadding, left/right from msg.sidePadding</pre>
530
+
531
+ <h4>Colorful Borders</h4>
532
+ <pre>// Add colored border for visual emphasis
533
+ {
534
+ top: 5, bottom: 5, left: 5, right: 5,
535
+ padColor: "#FF0000" // Red border
536
+ }</pre>
537
+
538
+ <h3>Node Interactions</h3>
539
+ <h4>Pre-Processing Chain</h4>
540
+ <ul>
541
+ <li><strong>image-in → crop → padding:</strong> Crop then add border</li>
542
+ <li><strong>array-select → padding:</strong> Add padding to selected images</li>
543
+ <li><strong>filter → padding:</strong> Apply effects then add border frame</li>
544
+ </ul>
545
+
546
+ <h4>Post-Processing Chain</h4>
547
+ <ul>
548
+ <li><strong>padding → resize:</strong> Add padding then scale to final size</li>
549
+ <li><strong>padding → concat:</strong> Pad images before combining</li>
550
+ <li><strong>padding → array-out:</strong> Apply borders then encode for output</li>
551
+ </ul>
552
+
553
+ <h4>Common Workflows</h4>
554
+ <ul>
555
+ <li><strong>Thumbnail Generation:</strong> resize → padding → array-out (consistent dimensions)</li>
556
+ <li><strong>Gallery Layout:</strong> padding → concat → mosaic (spaced grid layout)</li>
557
+ <li><strong>Frame Creation:</strong> padding → filter → padding (nested border effects)</li>
558
+ </ul>
559
+
560
+ <h3>Output Formats</h3>
561
+ <dl class="message-properties">
562
+ <dt>raw <span class="property-type">object</span></dt>
563
+ <dd>Fastest option. Returns processed image object for further Node-RED processing</dd>
564
+
565
+ <dt>jpg <span class="property-type">Buffer</span></dt>
566
+ <dd>JPEG-compressed buffer with configurable quality (1-100). Good for photographs</dd>
567
+
568
+ <dt>png <span class="property-type">Buffer</span></dt>
569
+ <dd>PNG-compressed buffer with lossless compression. Preserves transparency</dd>
570
+
571
+ <dt>webp <span class="property-type">Buffer</span></dt>
572
+ <dd>WebP-compressed buffer with configurable quality. Modern format with excellent compression</dd>
573
+ </dl>
574
+
575
+ <h3>Error Handling</h3>
576
+ <ul>
577
+ <li><strong>Invalid Input:</strong> Non-image objects trigger warnings and prevent processing</li>
578
+ <li><strong>Negative Margins:</strong> Values < 0 are treated as 0 with warning</li>
579
+ <li><strong>Missing Properties:</strong> Incomplete image objects are rejected with detailed error messages</li>
580
+ <li><strong>Memory Limits:</strong> Very large padding operations may fail with memory errors</li>
581
+ <li><strong>Color Format:</strong> Invalid hex colors default to black (#000000)</li>
582
+ <li><strong>Dynamic Values:</strong> Missing or invalid dynamic values default to 0</li>
583
+ </ul>
584
+
585
+ <h3>Performance</h3>
586
+ <ul>
587
+ <li><strong>C++ Backend:</strong> High-performance OpenCV-based processing</li>
588
+ <li><strong>Array Support:</strong> Parallel processing of image arrays using Promise.all()</li>
589
+ <li><strong>Memory Efficiency:</strong> Optimized memory allocation for large images</li>
590
+ <li><strong>Status Display:</strong> Real-time timing information (conversion, processing, encoding)</li>
591
+ <li><strong>Zero-Copy:</strong> Minimal memory copying for efficient processing</li>
592
+ <li><strong>Performance Metrics:</strong> Typical processing: <1ms per megapixel for raw output</li>
593
+ </ul>
594
+
595
+ <p><strong>Note:</strong> The node status bar displays detailed timing information: conversion time (input processing) + task time (padding operation) + encoding time (output formatting).</p>
596
+ </script>
597
+
598
+ <script type="text/x-red" data-help-name="padding">
288
599
  <p>The <strong>padding</strong> node adds solid color borders around images with pixel-perfect precision. It supports independent margin control for each side and works with both single images and arrays, using high-performance C++ backend processing with OpenCV.</p>
289
600
 
290
601
  <h3>Details</h3>
@@ -67,6 +67,8 @@ module.exports = function (RED) {
67
67
  const outputFormat = cfg.outputFormat || 'raw';
68
68
  const outputQuality = parseInt(cfg.outputQuality) || 90;
69
69
  const pngOptimize = cfg.pngOptimize || false;
70
+ const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(cfg);
71
+ const cppFormat = useSharpWebp ? 'raw' : outputFormat;
70
72
  const padHex = cfg.padColor || '#000000';
71
73
 
72
74
  /* numeric margins can come from msg / flow / global */
@@ -77,7 +79,7 @@ module.exports = function (RED) {
77
79
 
78
80
  /* one C++ call per image (fast, runs in parallel) */
79
81
  const tasks = imgs.map(img =>
80
- CppProcessor.padding(img, tVal, bVal, lVal, rVal, padHex, outputFormat, outputQuality, pngOptimize)
82
+ CppProcessor.padding(img, tVal, bVal, lVal, rVal, padHex, cppFormat, outputQuality, pngOptimize)
81
83
  );
82
84
  const results = await Promise.all(tasks);
83
85
 
@@ -90,6 +92,12 @@ module.exports = function (RED) {
90
92
  return r.image;
91
93
  });
92
94
 
95
+ if (useSharpWebp) {
96
+ for (let i = 0; i < outImgs.length; i++) {
97
+ outImgs[i] = await NodeUtils.encodeWebpAdvanced(outImgs[i], cfg);
98
+ }
99
+ }
100
+
93
101
  NodeUtils.setOutputValue(node, msg, outPath, outputPathType, Array.isArray(originalPayload) ? outImgs : outImgs[0]);
94
102
 
95
103
  // Debug image display
@@ -159,5 +167,6 @@ module.exports = function (RED) {
159
167
  });
160
168
  }
161
169
 
162
- RED.nodes.registerType('padding', PaddingNode);
170
+ RED.nodes.registerType('rp-padding', PaddingNode);
171
+ RED.nodes.registerType('padding', PaddingNode); // legacy compat
163
172
  };