@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,7 +1,7 @@
|
|
|
1
1
|
<!-- nodes/blend/add-masks.html -->
|
|
2
2
|
|
|
3
3
|
<script type="text/javascript">
|
|
4
|
-
|
|
4
|
+
var _rpNodeCfg = {
|
|
5
5
|
category:'RP Image',
|
|
6
6
|
color:'#DDA0DD',
|
|
7
7
|
icon:'font-awesome/fa-masks',
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
classColorMappings:{value:[]} // Array of {className, color} objects
|
|
25
25
|
},
|
|
26
26
|
inputs:1,outputs:1,
|
|
27
|
-
label:function(){return this.name||"add-masks";},
|
|
27
|
+
label:function(){return this.name||"rp-add-masks";},
|
|
28
28
|
oneditprepare:function(){
|
|
29
29
|
const node = this;
|
|
30
30
|
let classMappingIndex = 0;
|
|
@@ -435,7 +435,9 @@
|
|
|
435
435
|
|
|
436
436
|
this.classColorMappings = mappings;
|
|
437
437
|
}
|
|
438
|
-
}
|
|
438
|
+
};
|
|
439
|
+
RED.nodes.registerType('rp-add-masks', _rpNodeCfg);
|
|
440
|
+
RED.nodes.registerType('add-masks', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
439
441
|
|
|
440
442
|
// Debug image display renderer - shared across all image processing nodes
|
|
441
443
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -547,6 +549,107 @@
|
|
|
547
549
|
}
|
|
548
550
|
</script>
|
|
549
551
|
|
|
552
|
+
<script type="text/x-red" data-template-name="rp-add-masks">
|
|
553
|
+
<div class="form-row">
|
|
554
|
+
<label><i class="fa fa-picture-o"></i> Image</label>
|
|
555
|
+
<input type="text" id="node-input-imagePath" style="width:70%;">
|
|
556
|
+
<input type="hidden" id="node-input-imagePathType">
|
|
557
|
+
</div>
|
|
558
|
+
|
|
559
|
+
<div class="form-row">
|
|
560
|
+
<label><i class="fa fa-list"></i> Masks Array</label>
|
|
561
|
+
<input type="text" id="node-input-masksPath" style="width:70%;">
|
|
562
|
+
<input type="hidden" id="node-input-masksPathType">
|
|
563
|
+
</div>
|
|
564
|
+
|
|
565
|
+
<div class="form-row">
|
|
566
|
+
<label><i class="fa fa-sign-out"></i> Output</label>
|
|
567
|
+
<input type="text" id="node-input-outputPath" style="width:70%;">
|
|
568
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
569
|
+
</div>
|
|
570
|
+
|
|
571
|
+
<div class="form-row">
|
|
572
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
573
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
574
|
+
<option value="raw">Raw (fastest)</option>
|
|
575
|
+
<option value="jpg">JPEG</option>
|
|
576
|
+
<option value="png">PNG</option>
|
|
577
|
+
<option value="webp">WebP</option>
|
|
578
|
+
</select>
|
|
579
|
+
</div>
|
|
580
|
+
|
|
581
|
+
<div class="form-row" id="quality-row">
|
|
582
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
583
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
584
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
585
|
+
</div>
|
|
586
|
+
|
|
587
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
588
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
589
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
590
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
591
|
+
</div>
|
|
592
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
593
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
594
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
595
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
596
|
+
</div>
|
|
597
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
598
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
599
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
600
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
601
|
+
</div>
|
|
602
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
603
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
604
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
605
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
606
|
+
</div>
|
|
607
|
+
|
|
608
|
+
<!-- Debug Configuration -->
|
|
609
|
+
<div class="form-row">
|
|
610
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
611
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
612
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
613
|
+
</div>
|
|
614
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
615
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
616
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
617
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
618
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
619
|
+
</div>
|
|
620
|
+
|
|
621
|
+
<hr/>
|
|
622
|
+
|
|
623
|
+
<div class="form-row">
|
|
624
|
+
<label for="node-input-globalMaskStrength"><i class="fa fa-adjust"></i> Global Mask Strength</label>
|
|
625
|
+
<input type="range" id="node-input-globalMaskStrength" min="0" max="100" value="50" style="width: 200px;">
|
|
626
|
+
<span id="strength-value" style="margin-left: 10px; font-weight: bold;">50%</span>
|
|
627
|
+
<div style="margin-top: 5px; font-size: 11px; color: #666;" id="strength-label">
|
|
628
|
+
Balanced mask application
|
|
629
|
+
</div>
|
|
630
|
+
<div style="margin-top: 5px; font-size: 10px; color: #999;">
|
|
631
|
+
0% = No mask effect | 50% = Balanced | 100% = Full mask effect
|
|
632
|
+
</div>
|
|
633
|
+
</div>
|
|
634
|
+
|
|
635
|
+
<div class="form-row">
|
|
636
|
+
<label><i class="fa fa-palette"></i> Class Color Mappings</label>
|
|
637
|
+
<div id="class-mappings-container" style="margin-top: 10px;">
|
|
638
|
+
<!-- Dynamic class mapping rows will be inserted here -->
|
|
639
|
+
</div>
|
|
640
|
+
<div style="margin-top: 10px;">
|
|
641
|
+
<button type="button" id="add-class-mapping" class="editor-button">
|
|
642
|
+
<i class="fa fa-plus"></i> Add Class Mapping
|
|
643
|
+
</button>
|
|
644
|
+
</div>
|
|
645
|
+
<div style="margin-top: 5px; font-size: 11px; color: #666;">
|
|
646
|
+
<i class="fa fa-arrows-v"></i> Drag to reorder priority.
|
|
647
|
+
<strong>First = highest priority</strong> when masks overlap.
|
|
648
|
+
Undefined classes use auto-generated colors.
|
|
649
|
+
</div>
|
|
650
|
+
</div>
|
|
651
|
+
</script>
|
|
652
|
+
|
|
550
653
|
<script type="text/x-red" data-template-name="add-masks">
|
|
551
654
|
<div class="form-row">
|
|
552
655
|
<label><i class="fa fa-picture-o"></i> Image</label>
|
|
@@ -648,6 +751,83 @@
|
|
|
648
751
|
</div>
|
|
649
752
|
</script>
|
|
650
753
|
|
|
754
|
+
<script type="text/x-red" data-help-name="rp-add-masks">
|
|
755
|
+
<p><b>rosepetal-add-masks</b> applies multiple polygon-based masks to a base image using weighted blending with configurable mask strength and class-based color mapping. This node processes arrays of mask objects with automatic color assignment for different classes.</p>
|
|
756
|
+
|
|
757
|
+
<h3>Details</h3>
|
|
758
|
+
<p>This node performs high-performance multi-polygon-based blending using OpenCV. Binary masks are generated from polygon coordinates using OpenCV's fillPoly function, then applied to the base image as blending weights. Each mask can have a different color based on its class name. The polygon coordinates are expected to be normalized (0-1 range) and are automatically scaled to match the image dimensions.</p>
|
|
759
|
+
|
|
760
|
+
<h3>Properties</h3>
|
|
761
|
+
<dl class="message-properties">
|
|
762
|
+
<dt>Image <span class="property-type">string</span></dt>
|
|
763
|
+
<dd>Message property path containing the base image to which the masks will be applied (default: <code>msg.image</code>). Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
764
|
+
|
|
765
|
+
<dt>Masks Array <span class="property-type">string</span></dt>
|
|
766
|
+
<dd>Message property path containing the masks array (default: <code>msg.array</code>). Expected structure: direct array of mask objects with <code>polygons</code> coordinates and <code>tag</code> property. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
767
|
+
|
|
768
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
769
|
+
<dd>Message property path where the masked image will be stored (default: <code>msg.payload</code>). Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
770
|
+
|
|
771
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
772
|
+
<dd>Format for the output image: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
773
|
+
|
|
774
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
775
|
+
<dd>Compression quality (1-100) for JPEG and WebP formats. Only visible when JPG or WebP is selected.</dd>
|
|
776
|
+
|
|
777
|
+
<dt>Global Mask Strength <span class="property-type">number</span></dt>
|
|
778
|
+
<dd>Intensity of mask application from 0% to 100%. Controls how strongly all masks affect the final result.</dd>
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
<dt>Class Color Mappings <span class="property-type">array</span></dt>
|
|
782
|
+
<dd>Dynamic list of tag name to color mappings. Each mapping defines a specific color for masks with that tag. Supports adding and removing mappings.</dd>
|
|
783
|
+
</dl>
|
|
784
|
+
|
|
785
|
+
<h3>Input Structure</h3>
|
|
786
|
+
<p>The masks array should follow this exact structure (direct array of mask objects):</p>
|
|
787
|
+
<pre>[
|
|
788
|
+
{
|
|
789
|
+
"tag": "bottle",
|
|
790
|
+
"polygons": [[[0.107, 0.141], [0.211, 0.141], [0.211, 0.930], [0.107, 0.930]]],
|
|
791
|
+
"confidence": 0.9697,
|
|
792
|
+
"color": "rgb(144,133,227)", // Ignored - use class color mappings instead
|
|
793
|
+
"classId": 0, // Ignored
|
|
794
|
+
"raw_boxes": [...], // Ignored
|
|
795
|
+
"area": 0.072 // Ignored
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
"tag": "mountain",
|
|
799
|
+
"polygons": [[[0.283, 0.158], [0.391, 0.158], [0.391, 0.963], [0.283, 0.963]]],
|
|
800
|
+
"confidence": 0.9648
|
|
801
|
+
}
|
|
802
|
+
]</pre>
|
|
803
|
+
<p><b>Note:</b> Only <code>tag</code> and <code>polygons</code> fields are used. Other fields (color, classId, raw_boxes, area, confidence) are ignored.</p>
|
|
804
|
+
|
|
805
|
+
<h3>Key Features</h3>
|
|
806
|
+
<ul>
|
|
807
|
+
<li><b>Dynamic Color Management:</b> Add/remove tag color mappings with real-time validation</li>
|
|
808
|
+
<li><b>Auto-Color Generation:</b> Consistent random colors for undefined tags using maximally different color algorithm</li>
|
|
809
|
+
<li><b>Duplicate Detection:</b> Visual warnings for duplicate tags and similar colors</li>
|
|
810
|
+
<li><b>Multi-Layer Blending:</b> Proper compositing of multiple masks with weight normalization</li>
|
|
811
|
+
<li><b>Structure Validation:</b> Comprehensive validation of direct array structure</li>
|
|
812
|
+
</ul>
|
|
813
|
+
|
|
814
|
+
<h3>Color Management</h3>
|
|
815
|
+
<p>Colors are assigned using this priority order:</p>
|
|
816
|
+
<ol>
|
|
817
|
+
<li><b>User-defined mapping:</b> Colors explicitly set in the tag color mappings</li>
|
|
818
|
+
<li><b>Auto-generated:</b> Maximally different colors for undefined tags</li>
|
|
819
|
+
<li><b>Default fallback:</b> White color (#ffffff)</li>
|
|
820
|
+
</ol>
|
|
821
|
+
|
|
822
|
+
<h3>Performance</h3>
|
|
823
|
+
<ul>
|
|
824
|
+
<li><b>C++ Backend:</b> High-performance OpenCV implementation with SIMD optimizations</li>
|
|
825
|
+
<li><b>Batch Processing:</b> Efficient handling of multiple masks in single operation</li>
|
|
826
|
+
<li><b>Memory Efficient:</b> Optimized buffer handling and intermediate result reuse</li>
|
|
827
|
+
<li><b>Weight Normalization:</b> Prevents over-saturation when masks overlap</li>
|
|
828
|
+
</ul>
|
|
829
|
+
</script>
|
|
830
|
+
|
|
651
831
|
<script type="text/x-red" data-help-name="add-masks">
|
|
652
832
|
<p><b>rosepetal-add-masks</b> applies multiple polygon-based masks to a base image using weighted blending with configurable mask strength and class-based color mapping. This node processes arrays of mask objects with automatic color assignment for different classes.</p>
|
|
653
833
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- nodes/blend/blend.html -->
|
|
2
2
|
|
|
3
3
|
<script type="text/javascript">
|
|
4
|
-
|
|
4
|
+
var _rpNodeCfg = {
|
|
5
5
|
category:'RP Image',
|
|
6
6
|
color:'#DDA0DD',
|
|
7
7
|
icon:'font-awesome/fa-adjust',
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
colorTolerance:{value:10} // Color tolerance 0-100%
|
|
29
29
|
},
|
|
30
30
|
inputs:1,outputs:1,
|
|
31
|
-
label:function(){return this.name||"blend";},
|
|
31
|
+
label:function(){return this.name||"rp-blend";},
|
|
32
32
|
oneditprepare:function(){
|
|
33
33
|
/* path typedInputs */
|
|
34
34
|
$("#node-input-image1Path").typedInput({
|
|
@@ -159,7 +159,9 @@
|
|
|
159
159
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
}
|
|
162
|
+
};
|
|
163
|
+
RED.nodes.registerType('rp-blend', _rpNodeCfg);
|
|
164
|
+
RED.nodes.registerType('blend', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
163
165
|
|
|
164
166
|
// Debug image display renderer - shared across all image processing nodes
|
|
165
167
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -271,6 +273,123 @@
|
|
|
271
273
|
}
|
|
272
274
|
</script>
|
|
273
275
|
|
|
276
|
+
<script type="text/x-red" data-template-name="rp-blend">
|
|
277
|
+
<div class="form-row">
|
|
278
|
+
<label><i class="fa fa-picture-o"></i> Image 1</label>
|
|
279
|
+
<input type="text" id="node-input-image1Path" style="width:70%;">
|
|
280
|
+
<input type="hidden" id="node-input-image1PathType">
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div class="form-row">
|
|
284
|
+
<label><i class="fa fa-picture-o"></i> Image 2</label>
|
|
285
|
+
<input type="text" id="node-input-image2Path" style="width:70%;">
|
|
286
|
+
<input type="hidden" id="node-input-image2PathType">
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
<div class="form-row">
|
|
290
|
+
<label><i class="fa fa-sign-out"></i> Output</label>
|
|
291
|
+
<input type="text" id="node-input-outputPath" style="width:70%;">
|
|
292
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
<div class="form-row">
|
|
296
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
297
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
298
|
+
<option value="raw">Raw (fastest)</option>
|
|
299
|
+
<option value="jpg">JPEG</option>
|
|
300
|
+
<option value="png">PNG</option>
|
|
301
|
+
<option value="webp">WebP</option>
|
|
302
|
+
</select>
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<div class="form-row" id="quality-row">
|
|
306
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
307
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
308
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
312
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
313
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
314
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
315
|
+
</div>
|
|
316
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
317
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
318
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
319
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
320
|
+
</div>
|
|
321
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
322
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
323
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
324
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
327
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
328
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
329
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
<!-- Debug Configuration -->
|
|
333
|
+
<div class="form-row">
|
|
334
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
335
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
336
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
337
|
+
</div>
|
|
338
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
339
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
340
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
341
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
342
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
<hr/>
|
|
346
|
+
|
|
347
|
+
<!-- Alpha Compositing Mode -->
|
|
348
|
+
<div class="form-row">
|
|
349
|
+
<label for="node-input-alphaCompositing"><i class="fa fa-layers"></i> Alpha Compositing</label>
|
|
350
|
+
<input type="checkbox" id="node-input-alphaCompositing" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
351
|
+
<label for="node-input-alphaCompositing" style="width:auto; margin-left:5px;">Use Image 1 as base layer</label>
|
|
352
|
+
<div style="margin-top: 5px; font-size: 10px; color: #999;">
|
|
353
|
+
When enabled: Image 1 = base, Image 2 = overlay with proper transparency support
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
|
|
357
|
+
<!-- Background Removal (only visible when alpha compositing enabled) -->
|
|
358
|
+
<div class="form-row" id="background-removal-row" style="display: none;">
|
|
359
|
+
<label for="node-input-removeBackground"><i class="fa fa-eraser"></i> Background Removal</label>
|
|
360
|
+
<input type="checkbox" id="node-input-removeBackground" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
361
|
+
<label for="node-input-removeBackground" style="width:auto; margin-left:5px;">Remove background from overlay image</label>
|
|
362
|
+
</div>
|
|
363
|
+
|
|
364
|
+
<div class="form-row" id="background-color-row" style="display: none;">
|
|
365
|
+
<label for="node-input-backgroundColor"><i class="fa fa-eyedropper"></i> Background Color</label>
|
|
366
|
+
<input type="color" id="node-input-backgroundColor" value="#ffffff" style="width: 60px; height: 30px;">
|
|
367
|
+
<span style="margin-left: 10px; color: #666;">Color to remove from overlay image</span>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
<div class="form-row" id="tolerance-row" style="display: none;">
|
|
371
|
+
<label for="node-input-colorTolerance"><i class="fa fa-crosshairs"></i> Color Tolerance</label>
|
|
372
|
+
<input type="range" id="node-input-colorTolerance" min="0" max="100" value="10" style="width: 200px;">
|
|
373
|
+
<span id="tolerance-value" style="margin-left: 10px; font-weight: bold;">10%</span>
|
|
374
|
+
<div style="margin-top: 5px; font-size: 10px; color: #999;">
|
|
375
|
+
0% = Exact match | 50% = Moderate tolerance | 100% = Maximum tolerance
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
|
|
379
|
+
<div class="form-row">
|
|
380
|
+
<label for="node-input-opacity"><i class="fa fa-adjust"></i> Opacity</label>
|
|
381
|
+
<input type="range" id="node-input-opacity" min="0" max="100" value="50" style="width: 200px;">
|
|
382
|
+
<span id="opacity-value" style="margin-left: 10px; font-weight: bold;">50%</span>
|
|
383
|
+
<div style="margin-top: 5px; font-size: 11px; color: #666;" id="opacity-label">
|
|
384
|
+
50% each image
|
|
385
|
+
</div>
|
|
386
|
+
<div style="margin-top: 5px; font-size: 10px; color: #999;" id="opacity-help">
|
|
387
|
+
Traditional: 0% = Image 2 only | 50% = Equal blend | 100% = Image 1 only<br/>
|
|
388
|
+
Alpha Compositing: 0% = Base only | 100% = Full overlay on base
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</script>
|
|
392
|
+
|
|
274
393
|
<script type="text/x-red" data-template-name="blend">
|
|
275
394
|
<div class="form-row">
|
|
276
395
|
<label><i class="fa fa-picture-o"></i> Image 1</label>
|
|
@@ -388,6 +507,192 @@
|
|
|
388
507
|
</div>
|
|
389
508
|
</script>
|
|
390
509
|
|
|
510
|
+
<script type="text/x-red" data-help-name="rp-blend">
|
|
511
|
+
<p><b>rosepetal-blend</b> combines two images using traditional blending or advanced alpha compositing with adjustable opacity. This node supports both mathematical blending and true layered compositing with transparency support and optional background removal.</p>
|
|
512
|
+
|
|
513
|
+
<h3>Details</h3>
|
|
514
|
+
<p>This node offers two distinct blending modes:</p>
|
|
515
|
+
<ul>
|
|
516
|
+
<li><b>Traditional Blending:</b> Mathematical mixing using OpenCV's <code>addWeighted</code> function</li>
|
|
517
|
+
<li><b>Alpha Compositing:</b> True layered compositing with transparency support, background removal, and proper alpha channel handling</li>
|
|
518
|
+
</ul>
|
|
519
|
+
<p>The opacity slider controls the contribution of each image to the final result. Images with different dimensions are automatically resized to match, and color space conversions are handled transparently. Alpha compositing mode enables proper PNG transparency handling and color-based background removal.</p>
|
|
520
|
+
|
|
521
|
+
<h3>Properties</h3>
|
|
522
|
+
<dl class="message-properties">
|
|
523
|
+
<dt>Image 1 <span class="property-type">string</span></dt>
|
|
524
|
+
<dd>Message property path containing the first input image. This image's contribution increases as opacity approaches 100%. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
525
|
+
|
|
526
|
+
<dt>Image 2 <span class="property-type">string</span></dt>
|
|
527
|
+
<dd>Message property path containing the second input image. This image's contribution increases as opacity approaches 0%. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
528
|
+
|
|
529
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
530
|
+
<dd>Message property path where the blended image will be stored. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
531
|
+
|
|
532
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
533
|
+
<dd>Format for the output image: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
534
|
+
|
|
535
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
536
|
+
<dd>Compression quality (1-100) for JPEG and WebP formats. Only visible when JPG or WebP is selected.</dd>
|
|
537
|
+
|
|
538
|
+
<dt>Opacity <span class="property-type">number</span></dt>
|
|
539
|
+
<dd>Blend ratio from 0% to 100%. In traditional mode: controls mix ratio. In alpha compositing mode: controls overlay opacity on base image.</dd>
|
|
540
|
+
|
|
541
|
+
<dt>Alpha Compositing <span class="property-type">boolean</span></dt>
|
|
542
|
+
<dd>Enable alpha compositing mode where Image 1 becomes the base layer and Image 2 becomes the overlay with proper transparency support.</dd>
|
|
543
|
+
|
|
544
|
+
<dt>Background Removal <span class="property-type">boolean</span></dt>
|
|
545
|
+
<dd>Remove specified background color from the overlay image (Image 2) before compositing. Only available in alpha compositing mode.</dd>
|
|
546
|
+
|
|
547
|
+
<dt>Background Color <span class="property-type">color</span></dt>
|
|
548
|
+
<dd>Color to remove from the overlay image. Uses HSV color space matching with configurable tolerance.</dd>
|
|
549
|
+
|
|
550
|
+
<dt>Color Tolerance <span class="property-type">number</span></dt>
|
|
551
|
+
<dd>Tolerance for background color matching (0-100%). Higher values remove more similar colors.</dd>
|
|
552
|
+
</dl>
|
|
553
|
+
|
|
554
|
+
<h3>Inputs</h3>
|
|
555
|
+
<p>Requires two input images from the specified message property paths:</p>
|
|
556
|
+
<ul>
|
|
557
|
+
<li><b>Image 1:</b> From the path specified in "Image 1" field (default: <code>msg.payload.image1</code>)</li>
|
|
558
|
+
<li><b>Image 2:</b> From the path specified in "Image 2" field (default: <code>msg.payload.image2</code>)</li>
|
|
559
|
+
</ul>
|
|
560
|
+
|
|
561
|
+
<p>Each image should follow the standard format:</p>
|
|
562
|
+
<pre>{
|
|
563
|
+
data: Buffer, // Raw pixel data or encoded file buffer
|
|
564
|
+
width: number, // Image width in pixels
|
|
565
|
+
height: number, // Image height in pixels
|
|
566
|
+
channels: number, // Channel count (1=grayscale, 3=RGB, 4=RGBA)
|
|
567
|
+
colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
|
|
568
|
+
dtype: string // "uint8", "uint16", "float32"
|
|
569
|
+
}</pre>
|
|
570
|
+
<p>File buffers (JPEG, PNG, WebP, BMP) are automatically detected and decoded.</p>
|
|
571
|
+
|
|
572
|
+
<h3>Outputs</h3>
|
|
573
|
+
<p>Produces a single blended image in the specified format:</p>
|
|
574
|
+
<ul>
|
|
575
|
+
<li><b>Raw format:</b> Complete image object with pixel data and metadata</li>
|
|
576
|
+
<li><b>Encoded formats (JPG/PNG/WebP):</b> File buffer ready for storage or transmission</li>
|
|
577
|
+
</ul>
|
|
578
|
+
<p>Output dimensions match the larger of the two input images. Smaller images are automatically resized to prevent dimension mismatches.</p>
|
|
579
|
+
|
|
580
|
+
<h3>Blending Behavior</h3>
|
|
581
|
+
|
|
582
|
+
<h4>Traditional Blending Mode</h4>
|
|
583
|
+
<p>Mathematical mixing using OpenCV's <code>addWeighted</code> function:</p>
|
|
584
|
+
<ul>
|
|
585
|
+
<li><b>0%:</b> 100% Image 2, 0% Image 1</li>
|
|
586
|
+
<li><b>50%:</b> Equal contribution from both images</li>
|
|
587
|
+
<li><b>100%:</b> 100% Image 1, 0% Image 2</li>
|
|
588
|
+
</ul>
|
|
589
|
+
<pre>result = image1 × (opacity/100) + image2 × (1 - opacity/100)</pre>
|
|
590
|
+
|
|
591
|
+
<h4>Alpha Compositing Mode</h4>
|
|
592
|
+
<p>True layered compositing with transparency support:</p>
|
|
593
|
+
<ul>
|
|
594
|
+
<li><b>0%:</b> Base image only (overlay fully transparent)</li>
|
|
595
|
+
<li><b>50%:</b> Base image with 50% opacity overlay</li>
|
|
596
|
+
<li><b>100%:</b> Base image with full opacity overlay</li>
|
|
597
|
+
</ul>
|
|
598
|
+
<pre>result = overlay × (overlay_alpha × opacity) + base × (1 - overlay_alpha × opacity)</pre>
|
|
599
|
+
|
|
600
|
+
<h4>Background Removal Process</h4>
|
|
601
|
+
<p>When background removal is enabled in alpha compositing mode:</p>
|
|
602
|
+
<ol>
|
|
603
|
+
<li>Convert overlay image to HSV color space</li>
|
|
604
|
+
<li>Calculate color distance from target background color</li>
|
|
605
|
+
<li>Create alpha mask where matching pixels become transparent</li>
|
|
606
|
+
<li>Apply Gaussian blur for smooth edges</li>
|
|
607
|
+
<li>Perform alpha compositing with transparency</li>
|
|
608
|
+
</ol>
|
|
609
|
+
|
|
610
|
+
<h3>Automatic Image Processing</h3>
|
|
611
|
+
<h4>Dimension Handling</h4>
|
|
612
|
+
<ul>
|
|
613
|
+
<li><b>Same Size:</b> Direct blending with no resizing</li>
|
|
614
|
+
<li><b>Different Sizes:</b> Smaller image is resized to match the larger one using high-quality interpolation</li>
|
|
615
|
+
<li><b>Aspect Ratio:</b> Preserved during resize operations to prevent distortion</li>
|
|
616
|
+
</ul>
|
|
617
|
+
|
|
618
|
+
<h4>Color Space Conversion</h4>
|
|
619
|
+
<ul>
|
|
620
|
+
<li><b>Automatic Detection:</b> Color spaces are detected from image metadata or inferred from channel count</li>
|
|
621
|
+
<li><b>Smart Conversion:</b> Images are converted to a common format for blending (RGBA > BGRA > RGB > BGR > GRAY priority)</li>
|
|
622
|
+
<li><b>Quality Preservation:</b> Lossless conversions maintain image quality throughout the process</li>
|
|
623
|
+
</ul>
|
|
624
|
+
|
|
625
|
+
<h3>Examples</h3>
|
|
626
|
+
<h4>Photo Double Exposure</h4>
|
|
627
|
+
<p>Create artistic double exposure effects:</p>
|
|
628
|
+
<ul>
|
|
629
|
+
<li>Input: Portrait + landscape images</li>
|
|
630
|
+
<li>Opacity: 60-80% for subtle overlay</li>
|
|
631
|
+
<li>Output: PNG for transparency support</li>
|
|
632
|
+
</ul>
|
|
633
|
+
|
|
634
|
+
<h4>Background Replacement</h4>
|
|
635
|
+
<p>Blend foreground object with new background:</p>
|
|
636
|
+
<ul>
|
|
637
|
+
<li>Image 1: Foreground with transparency</li>
|
|
638
|
+
<li>Image 2: New background</li>
|
|
639
|
+
<li>Opacity: 90-100% to preserve foreground</li>
|
|
640
|
+
</ul>
|
|
641
|
+
|
|
642
|
+
<h4>Watermark Application</h4>
|
|
643
|
+
<p>Add semi-transparent watermarks:</p>
|
|
644
|
+
<ul>
|
|
645
|
+
<li>Image 1: Main content</li>
|
|
646
|
+
<li>Image 2: Watermark/logo</li>
|
|
647
|
+
<li>Opacity: 80-95% for subtle branding</li>
|
|
648
|
+
</ul>
|
|
649
|
+
|
|
650
|
+
<h4>Transition Effects</h4>
|
|
651
|
+
<p>Create smooth transitions between images:</p>
|
|
652
|
+
<ul>
|
|
653
|
+
<li>Use with flow control to animate opacity</li>
|
|
654
|
+
<li>Multiple blend nodes for complex transitions</li>
|
|
655
|
+
<li>Real-time adjustment via message properties</li>
|
|
656
|
+
</ul>
|
|
657
|
+
|
|
658
|
+
<h3>Node Interactions</h3>
|
|
659
|
+
<ul>
|
|
660
|
+
<li><b>Upstream:</b> Works with <code>image-in</code>, <code>array-in</code>, or any nodes producing image pairs</li>
|
|
661
|
+
<li><b>Downstream:</b> Connect to image writers, further processing nodes, or display components</li>
|
|
662
|
+
<li><b>Chaining:</b> Can be chained for complex multi-layer compositions</li>
|
|
663
|
+
<li><b>Flow Integration:</b> Supports flow and global context for cross-node data sharing</li>
|
|
664
|
+
</ul>
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
<h3>Error Handling</h3>
|
|
668
|
+
<ul>
|
|
669
|
+
<li><b>Missing Images:</b> Clear warnings when either input image is missing or invalid</li>
|
|
670
|
+
<li><b>Dimension Mismatch:</b> Automatic resizing with performance-optimized interpolation</li>
|
|
671
|
+
<li><b>Color Space Issues:</b> Intelligent conversion with format preservation</li>
|
|
672
|
+
<li><b>Memory Management:</b> Efficient processing of large images with automatic cleanup</li>
|
|
673
|
+
<li><b>Format Compatibility:</b> Graceful handling of different input formats and encodings</li>
|
|
674
|
+
</ul>
|
|
675
|
+
|
|
676
|
+
<h3>Performance</h3>
|
|
677
|
+
<ul>
|
|
678
|
+
<li><b>C++ Backend:</b> High-performance OpenCV implementation with SIMD optimizations</li>
|
|
679
|
+
<li><b>Memory Efficient:</b> Minimal memory allocation with intelligent buffer reuse</li>
|
|
680
|
+
<li><b>Parallel Processing:</b> Multi-threaded operations for large images</li>
|
|
681
|
+
<li><b>Status Timing:</b> Real-time metrics showing conversion, processing, and encoding times</li>
|
|
682
|
+
<li><b>Zero-Copy Operations:</b> Efficient data transfer between JavaScript and C++ layers</li>
|
|
683
|
+
<li><b>Optimized Builds:</b> Compiled with <code>-O3</code>, <code>-march=native</code> for maximum performance</li>
|
|
684
|
+
</ul>
|
|
685
|
+
|
|
686
|
+
<h3>Advanced Features</h3>
|
|
687
|
+
<ul>
|
|
688
|
+
<li><b>Live Preview:</b> Debug mode shows blended result in real-time</li>
|
|
689
|
+
<li><b>Opacity Animation:</b> Programmatic control for animated blending effects</li>
|
|
690
|
+
<li><b>Batch Processing:</b> Efficient handling of multiple image pairs</li>
|
|
691
|
+
<li><b>Context Integration:</b> Full support for flow and global context storage</li>
|
|
692
|
+
<li><b>Format Flexibility:</b> Seamless conversion between raw and encoded formats</li>
|
|
693
|
+
</ul>
|
|
694
|
+
</script>
|
|
695
|
+
|
|
391
696
|
<script type="text/x-red" data-help-name="blend">
|
|
392
697
|
<p><b>rosepetal-blend</b> combines two images using traditional blending or advanced alpha compositing with adjustable opacity. This node supports both mathematical blending and true layered compositing with transparency support and optional background removal.</p>
|
|
393
698
|
|