@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
@@ -80,7 +80,7 @@
80
80
  };
81
81
  }
82
82
 
83
- RED.nodes.registerType('draw', {
83
+ var _rpNodeCfg = {
84
84
  category: 'RP Image',
85
85
  color: '#DDA0DD',
86
86
  defaults: {
@@ -92,6 +92,9 @@
92
92
  outputFormat: { value: "raw" },
93
93
  outputQuality: { value: 90 },
94
94
  pngOptimize: { value: false },
95
+ webpLossless: { value: false },
96
+ webpSmartSubsample: { value: false },
97
+ webpEffort: { value: "" },
95
98
  debugEnabled: { value: false },
96
99
  debugWidth: { value: 200 },
97
100
  debugWidthType: { value: "num" },
@@ -102,7 +105,7 @@
102
105
  outputs: 1,
103
106
  icon: "font-awesome/fa-paint-brush",
104
107
  label: function () {
105
- return this.name || "draw";
108
+ return this.name || "rp-draw";
106
109
  },
107
110
  oneditprepare: function () {
108
111
  const node = this;
@@ -130,6 +133,12 @@
130
133
  const format = $('#node-input-outputFormat').val();
131
134
  $('#quality-row').toggle(format === 'jpg' || format === 'webp');
132
135
  $('#png-optimize-row').toggle(format === 'png');
136
+
137
+ // Show WebP advanced options only when WebP is selected
138
+ const isWebp = format === 'webp';
139
+ $('#webp-lossless-row').toggle(isWebp);
140
+ $('#webp-smartsubsample-row').toggle(isWebp);
141
+ $('#webp-effort-row').toggle(isWebp);
133
142
  }
134
143
  $('#node-input-outputFormat').on('change', function () {
135
144
  updateQualityVisibility();
@@ -606,10 +615,118 @@
606
615
  this.points = readTableValues('points');
607
616
  this.lines = readTableValues('lines');
608
617
  }
609
- });
618
+ };
619
+ RED.nodes.registerType('rp-draw', _rpNodeCfg);
620
+ RED.nodes.registerType('draw', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
610
621
  })();
611
622
  </script>
612
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
+
613
730
  <script type="text/x-red" data-template-name="draw">
614
731
  <!-- Name -->
615
732
  <div class="form-row">
@@ -649,6 +766,21 @@
649
766
  <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
650
767
  <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG output</label>
651
768
  </div>
769
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
770
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
771
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
772
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
773
+ </div>
774
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
775
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
776
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
777
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
778
+ </div>
779
+ <div class="form-row" id="webp-effort-row" style="display: none;">
780
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
781
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
782
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
783
+ </div>
652
784
 
653
785
  <!-- Debug configuration -->
654
786
  <div class="form-row">
@@ -701,6 +833,23 @@
701
833
  </div>
702
834
  </script>
703
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
+
704
853
  <script type="text/x-red" data-help-name="draw">
705
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>
706
855
 
@@ -44,6 +44,8 @@ module.exports = function (RED) {
44
44
  const outputFormat = config.outputFormat || 'raw';
45
45
  const outputQuality = parseInt(config.outputQuality, 10) || 90;
46
46
  const pngOptimize = config.pngOptimize || false;
47
+ const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
48
+ const cppFormat = useSharpWebp ? 'raw' : outputFormat;
47
49
 
48
50
  const baseImage = NodeUtils.validateImageStructure(originalPayload, node);
49
51
  if (!baseImage) {
@@ -60,15 +62,19 @@ module.exports = function (RED) {
60
62
  node.warn('No valid points or lines configured. Outputting original image.');
61
63
  }
62
64
 
63
- const { image: resultImage, timing = {} } = await CppProcessor.draw(
65
+ let { image: resultImage, timing = {} } = await CppProcessor.draw(
64
66
  baseImage,
65
67
  resolvedPoints,
66
68
  resolvedLines,
67
- outputFormat,
69
+ cppFormat,
68
70
  outputQuality,
69
71
  pngOptimize
70
72
  );
71
73
 
74
+ if (useSharpWebp) {
75
+ resultImage = await NodeUtils.encodeWebpAdvanced(resultImage, config);
76
+ }
77
+
72
78
  NodeUtils.setOutputValue(node, msg, outputPath, outputPathType, resultImage);
73
79
 
74
80
  const elapsed = performance.now() - startTime;
@@ -526,5 +532,6 @@ module.exports = function (RED) {
526
532
  }
527
533
  }
528
534
 
529
- RED.nodes.registerType('draw', DrawNode);
535
+ RED.nodes.registerType('rp-draw', DrawNode);
536
+ RED.nodes.registerType('draw', DrawNode); // legacy compat
530
537
  };