@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.
- package/.github/workflows/build-prebuild.yml +3 -0
- package/install.sh +8 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +64 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +242 -3
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +10 -3
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +282 -4
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +15 -8
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +206 -3
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +10 -3
- package/node-red-contrib-image-tools/nodes/blend/blend.html +332 -4
- package/node-red-contrib-image-tools/nodes/blend/blend.js +10 -3
- 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 +398 -3
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +11 -4
- package/node-red-contrib-image-tools/nodes/mix/concat.html +245 -5
- package/node-red-contrib-image-tools/nodes/mix/concat.js +10 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +307 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +10 -3
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +217 -4
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +11 -2
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +285 -4
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +9 -2
- package/node-red-contrib-image-tools/nodes/transform/color-convert.html +169 -6
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/crop.html +237 -5
- package/node-red-contrib-image-tools/nodes/transform/crop.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/draw.html +152 -3
- package/node-red-contrib-image-tools/nodes/transform/draw.js +10 -3
- package/node-red-contrib-image-tools/nodes/transform/filter.html +369 -4
- package/node-red-contrib-image-tools/nodes/transform/filter.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/padding.html +316 -5
- package/node-red-contrib-image-tools/nodes/transform/padding.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/resize.html +203 -5
- package/node-red-contrib-image-tools/nodes/transform/resize.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +164 -5
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +11 -2
- package/package.json +71 -71
- package/scripts/dual-register.js +267 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- 1 ▸ Runtime registration -->
|
|
4
4
|
<script type="text/javascript">
|
|
5
|
-
|
|
5
|
+
var _rpNodeCfg = {
|
|
6
6
|
|
|
7
7
|
category:'RP Image',
|
|
8
8
|
color :'#DA70D6',
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
outputFormat:{value:"raw"},
|
|
16
16
|
outputQuality:{value:90},
|
|
17
17
|
pngOptimize:{value:false},
|
|
18
|
+
webpLossless:{value:false},
|
|
19
|
+
webpSmartSubsample:{value:false},
|
|
20
|
+
webpEffort:{value:""},
|
|
18
21
|
// Debug configuration
|
|
19
22
|
debugEnabled:{value:false},
|
|
20
23
|
debugWidth:{value:200},
|
|
@@ -32,7 +35,7 @@
|
|
|
32
35
|
},
|
|
33
36
|
|
|
34
37
|
inputs:1, outputs:1,
|
|
35
|
-
label:function(){ return this.name || "advanced-mosaic"; },
|
|
38
|
+
label:function(){ return this.name || "rp-advanced-mosaic"; },
|
|
36
39
|
|
|
37
40
|
/* ---------------- oneditprepare ---------------- */
|
|
38
41
|
oneditprepare:function(){
|
|
@@ -74,6 +77,11 @@
|
|
|
74
77
|
const format = $("#node-input-outputFormat").val();
|
|
75
78
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
76
79
|
$("#png-optimize-row").toggle(format === "png");
|
|
80
|
+
// Show WebP advanced options only when WebP is selected
|
|
81
|
+
const isWebp = format === 'webp';
|
|
82
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
83
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
84
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
77
85
|
}
|
|
78
86
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
79
87
|
updateQualityVisibility(); // initial state
|
|
@@ -1679,7 +1687,9 @@
|
|
|
1679
1687
|
});
|
|
1680
1688
|
}, 100);
|
|
1681
1689
|
}
|
|
1682
|
-
}
|
|
1690
|
+
};
|
|
1691
|
+
RED.nodes.registerType('rp-advanced-mosaic', _rpNodeCfg);
|
|
1692
|
+
RED.nodes.registerType('advanced-mosaic', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
1683
1693
|
|
|
1684
1694
|
// Debug image display renderer - shared across all image processing nodes
|
|
1685
1695
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -1792,6 +1802,274 @@
|
|
|
1792
1802
|
</script>
|
|
1793
1803
|
|
|
1794
1804
|
<!-- 2 ▸ Edit‑dialog template -->
|
|
1805
|
+
<script type="text/x-red" data-template-name="rp-advanced-mosaic">
|
|
1806
|
+
|
|
1807
|
+
<!-- Name -->
|
|
1808
|
+
<div class="form-row">
|
|
1809
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
1810
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
1811
|
+
</div>
|
|
1812
|
+
|
|
1813
|
+
<hr>
|
|
1814
|
+
|
|
1815
|
+
<!-- STANDARD I/O SECTION -->
|
|
1816
|
+
<div class="form-row">
|
|
1817
|
+
<label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input from</label>
|
|
1818
|
+
<input type="text" id="node-input-inputPath" style="width: 70%;">
|
|
1819
|
+
<input type="hidden" id="node-input-inputPathType">
|
|
1820
|
+
</div>
|
|
1821
|
+
<div class="form-row">
|
|
1822
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
1823
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
1824
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
1825
|
+
</div>
|
|
1826
|
+
<div class="form-row">
|
|
1827
|
+
<label for="node-input-propagateMasks"><i class="fa fa-object-group"></i> Propagate masks</label>
|
|
1828
|
+
<input type="checkbox" id="node-input-propagateMasks" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
1829
|
+
<span style="margin-left: 6px; color: #666;">Apply same transforms to mask array</span>
|
|
1830
|
+
</div>
|
|
1831
|
+
<div class="form-row" id="mask-path-row">
|
|
1832
|
+
<label for="node-input-masksPath"><i class="fa fa-sign-in"></i> Masks from</label>
|
|
1833
|
+
<input type="text" id="node-input-masksPath" style="width: 70%;">
|
|
1834
|
+
<input type="hidden" id="node-input-masksPathType">
|
|
1835
|
+
</div>
|
|
1836
|
+
<div class="form-row" id="mask-output-path-row">
|
|
1837
|
+
<label for="node-input-masksOutputPath"><i class="fa fa-sign-out"></i> Masks to</label>
|
|
1838
|
+
<input type="text" id="node-input-masksOutputPath" style="width: 70%;">
|
|
1839
|
+
<input type="hidden" id="node-input-masksOutputPathType">
|
|
1840
|
+
</div>
|
|
1841
|
+
<div class="form-row">
|
|
1842
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
1843
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
1844
|
+
<option value="raw">Raw (fastest)</option>
|
|
1845
|
+
<option value="jpg">JPEG</option>
|
|
1846
|
+
<option value="png">PNG</option>
|
|
1847
|
+
<option value="webp">WebP</option>
|
|
1848
|
+
</select>
|
|
1849
|
+
</div>
|
|
1850
|
+
<div class="form-row" id="quality-row">
|
|
1851
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
1852
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
1853
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
1854
|
+
</div>
|
|
1855
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
1856
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
1857
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
1858
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
1859
|
+
</div>
|
|
1860
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
1861
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
1862
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
1863
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
1864
|
+
</div>
|
|
1865
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
1866
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
1867
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
1868
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
1869
|
+
</div>
|
|
1870
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
1871
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
1872
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
1873
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
1874
|
+
</div>
|
|
1875
|
+
|
|
1876
|
+
<!-- Debug Configuration -->
|
|
1877
|
+
<div class="form-row">
|
|
1878
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
1879
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
1880
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
1881
|
+
</div>
|
|
1882
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
1883
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
1884
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
1885
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
1886
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
1887
|
+
</div>
|
|
1888
|
+
|
|
1889
|
+
<hr>
|
|
1890
|
+
|
|
1891
|
+
<!-- CANVAS CONFIGURATION -->
|
|
1892
|
+
<div class="form-row">
|
|
1893
|
+
<label for="node-input-canvasWidth"><i class="fa fa-arrows-h"></i> Canvas Width</label>
|
|
1894
|
+
<input type="text" id="node-input-canvasWidth" style="width: 70%;" placeholder="800">
|
|
1895
|
+
<input type="hidden" id="node-input-canvasWidthType">
|
|
1896
|
+
</div>
|
|
1897
|
+
<div class="form-row">
|
|
1898
|
+
<label for="node-input-canvasHeight"><i class="fa fa-arrows-v"></i> Canvas Height</label>
|
|
1899
|
+
<input type="text" id="node-input-canvasHeight" style="width: 70%;" placeholder="600">
|
|
1900
|
+
<input type="hidden" id="node-input-canvasHeightType">
|
|
1901
|
+
</div>
|
|
1902
|
+
<div class="form-row">
|
|
1903
|
+
<label></label>
|
|
1904
|
+
<button type="button" id="actualize-canvas-btn" style="background: #4CAF50; color: white; border: none; padding: 8px 16px; cursor: pointer; border-radius: 4px; font-size: 12px;">
|
|
1905
|
+
Apply Canvas Size
|
|
1906
|
+
</button>
|
|
1907
|
+
<span style="margin-left: 10px; color: #666; font-size: 11px;">Click to apply canvas dimension changes</span>
|
|
1908
|
+
</div>
|
|
1909
|
+
<div class="form-row">
|
|
1910
|
+
<label for="node-input-backgroundColor"><i class="fa fa-paint-brush"></i> Background Color</label>
|
|
1911
|
+
<input type="color" id="node-input-backgroundColor" style="width: 70px; height: 30px;">
|
|
1912
|
+
</div>
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
<hr>
|
|
1916
|
+
|
|
1917
|
+
<!-- INTERACTIVE CANVAS EDITOR -->
|
|
1918
|
+
<div class="form-row">
|
|
1919
|
+
<label style="width: 100%; margin-bottom: 10px;"><i class="fa fa-th-large"></i> Visual Canvas Editor</label>
|
|
1920
|
+
|
|
1921
|
+
<!-- Canvas Controls -->
|
|
1922
|
+
<div style="display: flex; gap: 10px; margin-bottom: 10px; align-items: center;">
|
|
1923
|
+
<button type="button" id="add-image-config" style="background: #4CAF50; color: white; border: none; padding: 6px 12px; cursor: pointer; font-size: 12px;">Add Image</button>
|
|
1924
|
+
<button type="button" id="remove-selected-config" style="background: #ff4444; color: white; border: none; padding: 6px 12px; cursor: pointer; font-size: 12px;" disabled>Remove Selected</button>
|
|
1925
|
+
<label style="display: flex; align-items: center; gap: 5px; margin-left: auto;">
|
|
1926
|
+
<input type="checkbox" id="show-grid" checked> Show Grid
|
|
1927
|
+
</label>
|
|
1928
|
+
<label style="display: flex; align-items: center; gap: 5px;">
|
|
1929
|
+
<input type="checkbox" id="snap-to-grid" checked> Snap to Grid
|
|
1930
|
+
</label>
|
|
1931
|
+
<label style="display: flex; align-items: center; gap: 5px;">
|
|
1932
|
+
<input type="checkbox" id="magnetic-snap" checked> Magnetic Snap
|
|
1933
|
+
</label>
|
|
1934
|
+
<label style="display: flex; align-items: center; gap: 5px;">
|
|
1935
|
+
<input type="checkbox" id="preserve-aspect" checked> Lock Aspect Ratio
|
|
1936
|
+
</label>
|
|
1937
|
+
</div>
|
|
1938
|
+
|
|
1939
|
+
<!-- Canvas Container -->
|
|
1940
|
+
<div id="canvas-container" style="border: 2px solid #ddd; background: #f9f9f9; position: relative; margin-bottom: 10px; width: 100%; min-height: 300px; display: flex; justify-content: center; align-items: center;">
|
|
1941
|
+
<canvas id="mosaic-canvas" width="400" height="300" style="display: block; cursor: default; border: 1px solid #ccc;"></canvas>
|
|
1942
|
+
</div>
|
|
1943
|
+
|
|
1944
|
+
<!-- Selected Image Properties -->
|
|
1945
|
+
<div id="selected-properties" style="display: none; background: #f0f0f0; padding: 10px; border-radius: 4px; font-size: 12px;">
|
|
1946
|
+
<strong>Selected Image Properties:</strong>
|
|
1947
|
+
|
|
1948
|
+
<!-- Input Dimensions Section -->
|
|
1949
|
+
<div style="background: #e8f4fd; padding: 8px; margin: 8px 0; border-radius: 4px;">
|
|
1950
|
+
<strong style="color: #1976d2;">Input Dimensions (Original Image):</strong>
|
|
1951
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 8px;">
|
|
1952
|
+
<div>
|
|
1953
|
+
<label>Array Index:</label>
|
|
1954
|
+
<input type="number" id="prop-array-index" min="0" style="width: 100%; font-size: 11px; background-color: #f5f5f5;" readonly>
|
|
1955
|
+
<small style="color: #999; font-size: 9px;">🔒 Locked</small>
|
|
1956
|
+
</div>
|
|
1957
|
+
<div>
|
|
1958
|
+
<label>Input Width:</label>
|
|
1959
|
+
<input type="number" id="prop-input-width" min="1" style="width: 100%; font-size: 11px; background-color: #f5f5f5;" placeholder="800" readonly>
|
|
1960
|
+
<small style="color: #999; font-size: 9px;">🔒 Locked</small>
|
|
1961
|
+
</div>
|
|
1962
|
+
<div>
|
|
1963
|
+
<label>Input Height:</label>
|
|
1964
|
+
<input type="number" id="prop-input-height" min="1" style="width: 100%; font-size: 11px; background-color: #f5f5f5;" placeholder="600" readonly>
|
|
1965
|
+
<small style="color: #999; font-size: 9px;">🔒 Locked</small>
|
|
1966
|
+
</div>
|
|
1967
|
+
</div>
|
|
1968
|
+
<div style="margin-top: 5px;">
|
|
1969
|
+
<small style="color: #999; font-style: italic;">These values are locked after creation. Delete and recreate the image to change them.</small>
|
|
1970
|
+
</div>
|
|
1971
|
+
</div>
|
|
1972
|
+
|
|
1973
|
+
<!-- Resize & Transform Section -->
|
|
1974
|
+
<div style="background: #fff3e0; padding: 8px; margin: 8px 0; border-radius: 4px;">
|
|
1975
|
+
<strong style="color: #f57c00;">Resize & Transform:</strong>
|
|
1976
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 8px;">
|
|
1977
|
+
<div>
|
|
1978
|
+
<label>Resize Width:</label>
|
|
1979
|
+
<input type="number" id="prop-width" min="1" style="width: 100%; font-size: 11px;" placeholder="Keep original">
|
|
1980
|
+
</div>
|
|
1981
|
+
<div>
|
|
1982
|
+
<label>Resize Height:</label>
|
|
1983
|
+
<input type="number" id="prop-height" min="1" style="width: 100%; font-size: 11px;" placeholder="Keep original">
|
|
1984
|
+
</div>
|
|
1985
|
+
<div>
|
|
1986
|
+
<label>Rotation (°):</label>
|
|
1987
|
+
<input type="number" id="prop-rotation" step="any" style="width: 100%; font-size: 11px;">
|
|
1988
|
+
</div>
|
|
1989
|
+
</div>
|
|
1990
|
+
</div>
|
|
1991
|
+
|
|
1992
|
+
<!-- Computed Final Dimensions Section -->
|
|
1993
|
+
<div style="background: #e8f5e8; padding: 8px; margin: 8px 0; border-radius: 4px;">
|
|
1994
|
+
<strong style="color: #2e7d32;">Final Computed Dimensions:</strong>
|
|
1995
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 8px;">
|
|
1996
|
+
<div>
|
|
1997
|
+
<label>After Resize:</label>
|
|
1998
|
+
<input type="text" id="prop-computed-resize" readonly style="width: 100%; font-size: 11px; background: #f5f5f5;" placeholder="Computed...">
|
|
1999
|
+
</div>
|
|
2000
|
+
<div>
|
|
2001
|
+
<label>After Rotation:</label>
|
|
2002
|
+
<input type="text" id="prop-computed-final" readonly style="width: 100%; font-size: 11px; background: #f5f5f5;" placeholder="Computed...">
|
|
2003
|
+
</div>
|
|
2004
|
+
<div>
|
|
2005
|
+
<label>Expansion Factor:</label>
|
|
2006
|
+
<input type="text" id="prop-expansion-factor" readonly style="width: 100%; font-size: 11px; background: #f5f5f5;" placeholder="1.0x">
|
|
2007
|
+
</div>
|
|
2008
|
+
</div>
|
|
2009
|
+
</div>
|
|
2010
|
+
|
|
2011
|
+
<!-- Position Section -->
|
|
2012
|
+
<div style="background: #f3e5f5; padding: 8px; margin: 8px 0; border-radius: 4px;">
|
|
2013
|
+
<strong style="color: #7b1fa2;">Position & Actions:</strong>
|
|
2014
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 8px;">
|
|
2015
|
+
<div>
|
|
2016
|
+
<label>X Position:</label>
|
|
2017
|
+
<input type="number" id="prop-x" step="any" style="width: 100%; font-size: 11px;">
|
|
2018
|
+
</div>
|
|
2019
|
+
<div>
|
|
2020
|
+
<label>Y Position:</label>
|
|
2021
|
+
<input type="number" id="prop-y" step="any" style="width: 100%; font-size: 11px;">
|
|
2022
|
+
</div>
|
|
2023
|
+
<div>
|
|
2024
|
+
<label>Actions:</label>
|
|
2025
|
+
<div style="display: flex; gap: 4px; flex-wrap: wrap;">
|
|
2026
|
+
<button type="button" id="duplicate-selected" style="background: #2196F3; color: white; border: none; padding: 4px 8px; cursor: pointer; font-size: 10px;">Duplicate</button>
|
|
2027
|
+
</div>
|
|
2028
|
+
</div>
|
|
2029
|
+
</div>
|
|
2030
|
+
</div>
|
|
2031
|
+
|
|
2032
|
+
<!-- Layering Control Section -->
|
|
2033
|
+
<div style="background: #fff8e1; padding: 8px; margin: 8px 0; border-radius: 4px;">
|
|
2034
|
+
<strong style="color: #f57c00;">Layer Control (Z-Index):</strong>
|
|
2035
|
+
<div style="display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 8px;">
|
|
2036
|
+
<div>
|
|
2037
|
+
<label>Z-Index:</label>
|
|
2038
|
+
<input type="number" id="prop-z-index" style="width: 100%; font-size: 11px;">
|
|
2039
|
+
</div>
|
|
2040
|
+
<div>
|
|
2041
|
+
<label>Layer Actions:</label>
|
|
2042
|
+
<div style="display: flex; gap: 4px; flex-wrap: wrap;">
|
|
2043
|
+
<button type="button" id="bring-to-front" style="background: #4CAF50; color: white; border: none; padding: 4px 8px; cursor: pointer; font-size: 10px;">Bring to Front</button>
|
|
2044
|
+
<button type="button" id="send-to-back" style="background: #FF9800; color: white; border: none; padding: 4px 8px; cursor: pointer; font-size: 10px;">Send to Back</button>
|
|
2045
|
+
<button type="button" id="move-up" style="background: #2196F3; color: white; border: none; padding: 4px 8px; cursor: pointer; font-size: 10px;">Move Up</button>
|
|
2046
|
+
<button type="button" id="move-down" style="background: #9C27B0; color: white; border: none; padding: 4px 8px; cursor: pointer; font-size: 10px;">Move Down</button>
|
|
2047
|
+
</div>
|
|
2048
|
+
</div>
|
|
2049
|
+
</div>
|
|
2050
|
+
</div>
|
|
2051
|
+
</div>
|
|
2052
|
+
</div>
|
|
2053
|
+
|
|
2054
|
+
<div class="form-tips">
|
|
2055
|
+
<b>Enhanced Canvas Editor Instructions:</b>
|
|
2056
|
+
<ul>
|
|
2057
|
+
<li><b>Add Image:</b> Click "Add Image" to create a new placeholder rectangle</li>
|
|
2058
|
+
<li><b>Select & Drag:</b> Click on any placeholder to select it, then drag to reposition with magnetic snapping</li>
|
|
2059
|
+
<li><b>Resize with Aspect Ratio:</b> Drag resize handles to resize - aspect ratio is preserved by default, hold Shift to resize freely</li>
|
|
2060
|
+
<li><b>Accurate Preview:</b> The canvas shows exact dimensions matching the C++ processing pipeline</li>
|
|
2061
|
+
<li><b>Transparent Rotation:</b> Rotated images use transparent padding (diagonal pattern) allowing layered compositions</li>
|
|
2062
|
+
<li><b>Properties Panel:</b> Shows computed dimensions after resize and rotation, plus expansion factors</li>
|
|
2063
|
+
<li><b>Enhanced Grid Snapping:</b> Magnetic snap to grid lines, canvas borders, and other image edges</li>
|
|
2064
|
+
<li><b>Z-Index Control:</b> Visual depth indicators with easy layer management buttons (bring to front, send to back)</li>
|
|
2065
|
+
<li><b>Aspect Ratio Lock:</b> Toggle "Lock Aspect Ratio" to control default resize behavior</li>
|
|
2066
|
+
<li><b>Visual Feedback:</b> Colored snap lines appear during dragging, aspect ratio indicator shows during resize</li>
|
|
2067
|
+
<li><b>Color Coding:</b> Each array index has a unique color for easy identification</li>
|
|
2068
|
+
<li><b>Duplicate:</b> Use "Duplicate" button to copy the selected image configuration</li>
|
|
2069
|
+
</ul>
|
|
2070
|
+
</div>
|
|
2071
|
+
</script>
|
|
2072
|
+
|
|
1795
2073
|
<script type="text/x-red" data-template-name="advanced-mosaic">
|
|
1796
2074
|
|
|
1797
2075
|
<!-- Name -->
|
|
@@ -1847,6 +2125,21 @@
|
|
|
1847
2125
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
1848
2126
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
1849
2127
|
</div>
|
|
2128
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
2129
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
2130
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
2131
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
2132
|
+
</div>
|
|
2133
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
2134
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
2135
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
2136
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
2137
|
+
</div>
|
|
2138
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
2139
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
2140
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
2141
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
2142
|
+
</div>
|
|
1850
2143
|
|
|
1851
2144
|
<!-- Debug Configuration -->
|
|
1852
2145
|
<div class="form-row">
|
|
@@ -2046,6 +2339,108 @@
|
|
|
2046
2339
|
</script>
|
|
2047
2340
|
|
|
2048
2341
|
<!-- 3 ▸ Help panel -->
|
|
2342
|
+
<script type="text/x-red" data-help-name="rp-advanced-mosaic">
|
|
2343
|
+
<p><b>rosepetal-advanced-mosaic</b> creates composite images with per-image transformations including resize, rotate, and positioning. This advanced node extends the basic mosaic functionality by allowing individual transformation of each image before placement on the canvas.</p>
|
|
2344
|
+
|
|
2345
|
+
<h3>Details</h3>
|
|
2346
|
+
<p>This node processes arrays of images and applies individual transformations (resize, rotate) to each image before placing them on a customizable canvas. Each image can be independently resized, rotated, and positioned using an interactive visual canvas editor with drag-and-drop functionality.</p>
|
|
2347
|
+
|
|
2348
|
+
<h3>Properties</h3>
|
|
2349
|
+
<dl class="message-properties">
|
|
2350
|
+
<dt>Input from <span class="property-type">string</span></dt>
|
|
2351
|
+
<dd>Message property path containing the input image array.</dd>
|
|
2352
|
+
|
|
2353
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
2354
|
+
<dd>Message property path where the composite image will be stored.</dd>
|
|
2355
|
+
|
|
2356
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
2357
|
+
<dd>Format for the output image: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
2358
|
+
|
|
2359
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
2360
|
+
<dd>Compression quality (1-100) for JPEG and WebP formats.</dd>
|
|
2361
|
+
|
|
2362
|
+
<dt>Canvas Width/Height <span class="property-type">number|string</span></dt>
|
|
2363
|
+
<dd>Dimensions of the output canvas in pixels. Supports dynamic values from context.</dd>
|
|
2364
|
+
|
|
2365
|
+
<dt>Background Color <span class="property-type">color</span></dt>
|
|
2366
|
+
<dd>Canvas background color in hex format.</dd>
|
|
2367
|
+
|
|
2368
|
+
<dt>Normalized Coords <span class="property-type">boolean</span></dt>
|
|
2369
|
+
<dd>When enabled, position coordinates use normalized values (0.0-1.0).</dd>
|
|
2370
|
+
|
|
2371
|
+
<dt>Visual Canvas Editor <span class="property-type">interactive</span></dt>
|
|
2372
|
+
<dd>Interactive canvas interface for visually configuring image transformations with drag-and-drop positioning, magnetic helpers, and real-time preview.</dd>
|
|
2373
|
+
</dl>
|
|
2374
|
+
|
|
2375
|
+
<h3>Image Transformations</h3>
|
|
2376
|
+
<h4>Resize Options</h4>
|
|
2377
|
+
<ul>
|
|
2378
|
+
<li><b>Absolute Sizing:</b> Set specific width and height in pixels</li>
|
|
2379
|
+
<li><b>Aspect Ratio Preservation:</b> Specify only width or height to maintain proportions</li>
|
|
2380
|
+
<li><b>Original Size:</b> Leave width/height empty to use original dimensions</li>
|
|
2381
|
+
</ul>
|
|
2382
|
+
|
|
2383
|
+
<h4>Rotation System</h4>
|
|
2384
|
+
<ul>
|
|
2385
|
+
<li><b>Arbitrary Angles:</b> Rotate by any angle in degrees (counterclockwise positive)</li>
|
|
2386
|
+
<li><b>Optimized 90° Rotations:</b> Fast-path processing for 90°, 180°, 270°</li>
|
|
2387
|
+
<li><b>Transparent Padding:</b> Rotation expansion uses transparent padding for layered compositions</li>
|
|
2388
|
+
<li><b>Alpha Blending:</b> Rotated images blend seamlessly with underlying content</li>
|
|
2389
|
+
</ul>
|
|
2390
|
+
|
|
2391
|
+
<h4>Layering Control</h4>
|
|
2392
|
+
<ul>
|
|
2393
|
+
<li><b>Z-Index Ordering:</b> Control which images appear on top</li>
|
|
2394
|
+
<li><b>Automatic Z-Assignment:</b> Default ordering based on configuration sequence</li>
|
|
2395
|
+
</ul>
|
|
2396
|
+
|
|
2397
|
+
<h3>Performance Optimizations</h3>
|
|
2398
|
+
<ul>
|
|
2399
|
+
<li><b>C++ Backend:</b> High-performance OpenCV-based processing with SIMD acceleration</li>
|
|
2400
|
+
<li><b>Transformation Pipeline:</b> Optimized resize → rotate → place sequence</li>
|
|
2401
|
+
<li><b>Zero-Copy Operations:</b> Minimal memory allocation and copying</li>
|
|
2402
|
+
<li><b>Parallel Processing:</b> Multiple images processed concurrently when beneficial</li>
|
|
2403
|
+
<li><b>Fast-Path Rotations:</b> Optimized handling for common rotation angles</li>
|
|
2404
|
+
</ul>
|
|
2405
|
+
|
|
2406
|
+
<h3>Configuration Workflow</h3>
|
|
2407
|
+
<h4>Interactive Canvas Editor</h4>
|
|
2408
|
+
<ul>
|
|
2409
|
+
<li><b>Visual Positioning:</b> Drag-and-drop placeholder rectangles to position images</li>
|
|
2410
|
+
<li><b>Magnetic Helpers:</b> Snap-to-grid and alignment guides for precise positioning</li>
|
|
2411
|
+
<li><b>Properties Panel:</b> Fine-tune settings for selected images with numeric inputs</li>
|
|
2412
|
+
<li><b>Real-time Preview:</b> See exactly how your mosaic will look with color-coded placeholders</li>
|
|
2413
|
+
<li><b>Dynamic Management:</b> Add, remove, and duplicate image configurations with visual feedback</li>
|
|
2414
|
+
<li><b>Grid System:</b> Optional grid overlay with configurable snap-to-grid functionality</li>
|
|
2415
|
+
</ul>
|
|
2416
|
+
|
|
2417
|
+
<h3>Error Handling & Validation</h3>
|
|
2418
|
+
<ul>
|
|
2419
|
+
<li><b>Input Validation:</b> Comprehensive validation of image arrays and configurations</li>
|
|
2420
|
+
<li><b>Bounds Checking:</b> Automatic handling of out-of-bounds coordinates and indices</li>
|
|
2421
|
+
<li><b>Transformation Validation:</b> Safe handling of invalid resize and rotation parameters</li>
|
|
2422
|
+
<li><b>Canvas Validation:</b> Ensures valid canvas dimensions and background colors</li>
|
|
2423
|
+
<li><b>Warning System:</b> Non-fatal issues reported without stopping execution</li>
|
|
2424
|
+
</ul>
|
|
2425
|
+
|
|
2426
|
+
<h3>Example Configurations</h3>
|
|
2427
|
+
<h4>Photo Collage</h4>
|
|
2428
|
+
<ul>
|
|
2429
|
+
<li>Canvas: 1200x800 pixels, white background</li>
|
|
2430
|
+
<li>Image 0: Resize to 300x200, position at (50, 50)</li>
|
|
2431
|
+
<li>Image 1: Keep original size, rotate 15°, position at (400, 100)</li>
|
|
2432
|
+
<li>Image 2: Resize to 250x250, position at (700, 300)</li>
|
|
2433
|
+
</ul>
|
|
2434
|
+
|
|
2435
|
+
<h4>Dashboard Layout</h4>
|
|
2436
|
+
<ul>
|
|
2437
|
+
<li>Canvas: 1920x1080 pixels, dark background</li>
|
|
2438
|
+
<li>Header image: Full width resize, position at (0, 0)</li>
|
|
2439
|
+
<li>Sidebar: Fixed height, position at (0, 100)</li>
|
|
2440
|
+
<li>Main content: Scaled, position at (300, 100)</li>
|
|
2441
|
+
</ul>
|
|
2442
|
+
</script>
|
|
2443
|
+
|
|
2049
2444
|
<script type="text/x-red" data-help-name="advanced-mosaic">
|
|
2050
2445
|
<p><b>rosepetal-advanced-mosaic</b> creates composite images with per-image transformations including resize, rotate, and positioning. This advanced node extends the basic mosaic functionality by allowing individual transformation of each image before placement on the canvas.</p>
|
|
2051
2446
|
|
|
@@ -49,6 +49,8 @@ module.exports = function (RED) {
|
|
|
49
49
|
const outputFormat = config.outputFormat || 'raw';
|
|
50
50
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
51
51
|
const pngOptimize = config.pngOptimize || false;
|
|
52
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
53
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
52
54
|
const propagateMasks = !!config.propagateMasks;
|
|
53
55
|
const masksPath = config.masksPath || 'masks';
|
|
54
56
|
const masksPathType = config.masksPathType || 'msg';
|
|
@@ -115,7 +117,7 @@ module.exports = function (RED) {
|
|
|
115
117
|
|
|
116
118
|
/* Single ultra-fast C++ call */
|
|
117
119
|
const options = {
|
|
118
|
-
outputFormat,
|
|
120
|
+
outputFormat: cppFormat,
|
|
119
121
|
quality: outputQuality,
|
|
120
122
|
pngOptimize
|
|
121
123
|
};
|
|
@@ -123,7 +125,7 @@ module.exports = function (RED) {
|
|
|
123
125
|
options.masks = masksArray;
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
let { image, masks: transformedMasks, timing = {} } = await CppProcessor.advancedMosaic(
|
|
127
129
|
imageArray,
|
|
128
130
|
canvasWidth,
|
|
129
131
|
canvasHeight,
|
|
@@ -133,6 +135,10 @@ module.exports = function (RED) {
|
|
|
133
135
|
options
|
|
134
136
|
);
|
|
135
137
|
|
|
138
|
+
if (useSharpWebp) {
|
|
139
|
+
image = await NodeUtils.encodeWebpAdvanced(image, config);
|
|
140
|
+
}
|
|
141
|
+
|
|
136
142
|
const maskCount = Array.isArray(transformedMasks) ? transformedMasks.length : (propagateMasks && masksArray ? masksArray.length : 0);
|
|
137
143
|
|
|
138
144
|
/* Set output */
|
|
@@ -210,12 +216,13 @@ module.exports = function (RED) {
|
|
|
210
216
|
outputPath,
|
|
211
217
|
outputPathType,
|
|
212
218
|
outputType: 'single',
|
|
213
|
-
context: { inputPath, inputPathType, outputPath, outputPathType
|
|
219
|
+
context: { inputPath, inputPathType, outputPath, outputPathType }
|
|
214
220
|
}
|
|
215
221
|
);
|
|
216
222
|
}
|
|
217
223
|
});
|
|
218
224
|
}
|
|
219
225
|
|
|
220
|
-
RED.nodes.registerType('advanced-mosaic', AdvancedMosaicNode);
|
|
226
|
+
RED.nodes.registerType('rp-advanced-mosaic', AdvancedMosaicNode);
|
|
227
|
+
RED.nodes.registerType('advanced-mosaic', AdvancedMosaicNode); // legacy compat
|
|
221
228
|
};
|