@rosepetal/node-red-contrib-image-tools 1.1.3
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/.gitattributes +6 -0
- package/.github/workflows/build-prebuild.yml +326 -0
- package/LICENSE +13 -0
- package/README.md +161 -0
- package/artifacts/darwin-arm64/package.json +25 -0
- package/artifacts/linux-arm64/package.json +26 -0
- package/artifacts/linux-x64/package.json +26 -0
- package/artifacts/linuxmusl-x64/package.json +26 -0
- package/assets/flow_time_example.gif +0 -0
- package/assets/nodes/io/array-in-demo.gif +0 -0
- package/assets/nodes/io/array-out-demo.gif +0 -0
- package/assets/nodes/io/array-select-demo.gif +0 -0
- package/assets/nodes/io/image-in-demo.gif +0 -0
- package/assets/nodes/mix/concat-demo.gif +0 -0
- package/assets/nodes/mix/mosaic-demo.gif +0 -0
- package/assets/nodes/transform/crop-demo.gif +0 -0
- package/assets/nodes/transform/filter-demo.gif +0 -0
- package/assets/nodes/transform/padding-demo.gif +0 -0
- package/assets/nodes/transform/resize-demo.gif +0 -0
- package/assets/nodes/transform/rotate-demo.gif +0 -0
- package/docs/nodes/blend/add-mask.md +275 -0
- package/docs/nodes/blend/add-masks.md +284 -0
- package/docs/nodes/blend/blend.md +248 -0
- package/docs/nodes/io/array-in.md +119 -0
- package/docs/nodes/io/array-out.md +150 -0
- package/docs/nodes/io/array-select.md +157 -0
- package/docs/nodes/io/image-in.md +131 -0
- package/docs/nodes/io/image-out.md +179 -0
- package/docs/nodes/io/queue.md +57 -0
- package/docs/nodes/io/save-file.md +30 -0
- package/docs/nodes/mix/advanced-mosaic.md +108 -0
- package/docs/nodes/mix/concat.md +127 -0
- package/docs/nodes/mix/mosaic.md +146 -0
- package/docs/nodes/specialized/cropBB.md +271 -0
- package/docs/nodes/specialized/image-align.md +426 -0
- package/docs/nodes/transform/crop.md +132 -0
- package/docs/nodes/transform/draw.md +77 -0
- package/docs/nodes/transform/filter.md +84 -0
- package/docs/nodes/transform/padding.md +133 -0
- package/docs/nodes/transform/resize.md +158 -0
- package/docs/nodes/transform/rotate.md +121 -0
- package/docs/nodes/util/block-detect.md +46 -0
- package/install.sh +144 -0
- package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
- package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
- package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
- package/node-red-contrib-image-tools/package.json +64 -0
- package/npm/darwin-arm64/lib/.gitkeep +1 -0
- package/npm/darwin-arm64/package.json +25 -0
- package/npm/darwin-x64/lib/.gitkeep +1 -0
- package/npm/darwin-x64/package.json +25 -0
- package/npm/linux-arm64/lib/.gitkeep +1 -0
- package/npm/linux-arm64/package.json +26 -0
- package/npm/linux-x64/lib/.gitkeep +1 -0
- package/npm/linux-x64/package.json +26 -0
- package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
- package/npm/linuxmusl-x64/package.json +26 -0
- package/npm/win32-x64/lib/.gitkeep +1 -0
- package/npm/win32-x64/package.json +25 -0
- package/package.json +74 -0
- package/rosepetal-image-engine/binding.gyp +153 -0
- package/rosepetal-image-engine/package.json +19 -0
- package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
- package/rosepetal-image-engine/src/add-mask.cpp +240 -0
- package/rosepetal-image-engine/src/add-masks.cpp +638 -0
- package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
- package/rosepetal-image-engine/src/blend.cpp +200 -0
- package/rosepetal-image-engine/src/concat.cpp +329 -0
- package/rosepetal-image-engine/src/crop.cpp +139 -0
- package/rosepetal-image-engine/src/draw.cpp +414 -0
- package/rosepetal-image-engine/src/filter.cpp +230 -0
- package/rosepetal-image-engine/src/filters/kernels.h +171 -0
- package/rosepetal-image-engine/src/image-align.cpp +551 -0
- package/rosepetal-image-engine/src/main.cpp +36 -0
- package/rosepetal-image-engine/src/mosaic.cpp +373 -0
- package/rosepetal-image-engine/src/padding.cpp +124 -0
- package/rosepetal-image-engine/src/resize.cpp +210 -0
- package/rosepetal-image-engine/src/rotate.cpp +177 -0
- package/rosepetal-image-engine/src/utils.h +563 -0
- package/rosepetal-image-engine/test-formats.js +119 -0
- package/scripts/build-opencv-static.ps1 +166 -0
- package/scripts/build-opencv-static.sh +147 -0
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('filter', {
|
|
3
|
+
category: 'RP Image',
|
|
4
|
+
color: '#DDA0DD',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
// Standard I/O properties (same as other nodes)
|
|
8
|
+
inputPath: { value: "payload" },
|
|
9
|
+
inputPathType: { value: "msg" },
|
|
10
|
+
outputPath: { value: "payload" },
|
|
11
|
+
outputPathType: { value: "msg" },
|
|
12
|
+
outputFormat: { value: "raw" },
|
|
13
|
+
outputQuality: { value: 90 },
|
|
14
|
+
pngOptimize: { value: false },
|
|
15
|
+
// Debug configuration
|
|
16
|
+
debugEnabled: { value: false },
|
|
17
|
+
debugWidth: { value: 200 },
|
|
18
|
+
debugWidthType: { value: "num" },
|
|
19
|
+
// Filter-specific properties
|
|
20
|
+
filterType: { value: "blur" },
|
|
21
|
+
kernelSize: { value: "3" },
|
|
22
|
+
kernelSizeType: { value: "num" },
|
|
23
|
+
intensity: { value: "1.0" },
|
|
24
|
+
intensityType: { value: "num" }
|
|
25
|
+
},
|
|
26
|
+
inputs: 1,
|
|
27
|
+
outputs: 1,
|
|
28
|
+
icon: "font-awesome/fa-magic",
|
|
29
|
+
label: function() {
|
|
30
|
+
if (this.name) { return this.name; }
|
|
31
|
+
return `filter`;
|
|
32
|
+
},
|
|
33
|
+
oneditprepare: function() {
|
|
34
|
+
// === Standard I/O TypedInput initialization ===
|
|
35
|
+
$("#node-input-inputPath").typedInput({
|
|
36
|
+
default: 'msg',
|
|
37
|
+
types: ['msg', 'flow', 'global'],
|
|
38
|
+
typeField: "#node-input-inputPathType"
|
|
39
|
+
});
|
|
40
|
+
$("#node-input-outputPath").typedInput({
|
|
41
|
+
default: 'msg',
|
|
42
|
+
types: ['msg', 'flow', 'global'],
|
|
43
|
+
typeField: "#node-input-outputPathType"
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// === Filter-specific TypedInput initialization ===
|
|
47
|
+
$("#node-input-kernelSize").typedInput({
|
|
48
|
+
default: 'num',
|
|
49
|
+
types: ['num', 'msg', 'flow', 'global'],
|
|
50
|
+
typeField: "#node-input-kernelSizeType"
|
|
51
|
+
});
|
|
52
|
+
$("#node-input-intensity").typedInput({
|
|
53
|
+
default: 'num',
|
|
54
|
+
types: ['num', 'msg', 'flow', 'global'],
|
|
55
|
+
typeField: "#node-input-intensityType"
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// === Dynamic parameter updates based on filter type ===
|
|
59
|
+
function updateFilterParameters() {
|
|
60
|
+
const filterType = $("#node-input-filterType").val();
|
|
61
|
+
const kernelSizeRow = $("#kernel-size-row");
|
|
62
|
+
const intensityRow = $("#intensity-row");
|
|
63
|
+
const intensityLabel = $("#intensity-label");
|
|
64
|
+
|
|
65
|
+
// Show/hide and update labels based on filter type
|
|
66
|
+
switch (filterType) {
|
|
67
|
+
case 'blur':
|
|
68
|
+
kernelSizeRow.show();
|
|
69
|
+
intensityRow.show();
|
|
70
|
+
intensityLabel.text("Intensity");
|
|
71
|
+
break;
|
|
72
|
+
case 'sharpen':
|
|
73
|
+
kernelSizeRow.show();
|
|
74
|
+
intensityRow.show();
|
|
75
|
+
intensityLabel.text("Sharpness");
|
|
76
|
+
break;
|
|
77
|
+
case 'edge':
|
|
78
|
+
kernelSizeRow.show();
|
|
79
|
+
intensityRow.show();
|
|
80
|
+
intensityLabel.text("Edge Strength");
|
|
81
|
+
break;
|
|
82
|
+
case 'emboss':
|
|
83
|
+
kernelSizeRow.hide();
|
|
84
|
+
intensityRow.show();
|
|
85
|
+
intensityLabel.text("Emboss Depth");
|
|
86
|
+
break;
|
|
87
|
+
case 'gaussian':
|
|
88
|
+
kernelSizeRow.show();
|
|
89
|
+
intensityRow.show();
|
|
90
|
+
intensityLabel.text("Blur Radius");
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
kernelSizeRow.show();
|
|
94
|
+
intensityRow.show();
|
|
95
|
+
intensityLabel.text("Intensity");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Bind filter type change event
|
|
100
|
+
$("#node-input-filterType").on('change', updateFilterParameters);
|
|
101
|
+
|
|
102
|
+
// Initial parameter update
|
|
103
|
+
updateFilterParameters();
|
|
104
|
+
|
|
105
|
+
function updateQualityVisibility(){
|
|
106
|
+
const format = $("#node-input-outputFormat").val();
|
|
107
|
+
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
108
|
+
$("#png-optimize-row").toggle(format === "png");
|
|
109
|
+
}
|
|
110
|
+
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
111
|
+
updateQualityVisibility(); // initial state
|
|
112
|
+
|
|
113
|
+
// === Debug Display Logic ===
|
|
114
|
+
const debugCheckbox = $('#node-input-debugEnabled');
|
|
115
|
+
const debugWidthRow = $('#debug-width-row');
|
|
116
|
+
|
|
117
|
+
// Initialize debug width TypedInput
|
|
118
|
+
$("#node-input-debugWidth").typedInput({
|
|
119
|
+
default: 'num',
|
|
120
|
+
types: ['num', 'msg', 'flow', 'global'],
|
|
121
|
+
typeField: "#node-input-debugWidthType"
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Function to toggle debug width visibility
|
|
125
|
+
function updateDebugWidthVisibility() {
|
|
126
|
+
if (debugCheckbox.is(':checked')) {
|
|
127
|
+
debugWidthRow.show();
|
|
128
|
+
} else {
|
|
129
|
+
debugWidthRow.hide();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Initialize debug state on node open
|
|
134
|
+
updateDebugWidthVisibility();
|
|
135
|
+
|
|
136
|
+
// Handle debug checkbox changes
|
|
137
|
+
debugCheckbox.on('change', function() {
|
|
138
|
+
const enabled = this.checked;
|
|
139
|
+
updateDebugWidthVisibility();
|
|
140
|
+
// Store debug state for runtime access
|
|
141
|
+
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Debug image display renderer - shared across all image processing nodes
|
|
147
|
+
if (!window.debugImageRendererInitialized) {
|
|
148
|
+
window.debugImageRendererInitialized = true;
|
|
149
|
+
|
|
150
|
+
(function() {
|
|
151
|
+
var isSubscribed = false;
|
|
152
|
+
|
|
153
|
+
function subscribeToDebugImages() {
|
|
154
|
+
if (isSubscribed || typeof RED === 'undefined' || !RED.comms) return;
|
|
155
|
+
isSubscribed = true;
|
|
156
|
+
|
|
157
|
+
RED.comms.subscribe('debug-image', function(event, data) {
|
|
158
|
+
if (!data || !data.id) return;
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
renderDebugImage(data);
|
|
162
|
+
} catch (err) {
|
|
163
|
+
console.warn('Debug image render error:', err);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function renderDebugImage(data) {
|
|
169
|
+
const nodeId = data.id;
|
|
170
|
+
const base64Data = data.data;
|
|
171
|
+
const format = data.format || 'unknown';
|
|
172
|
+
const mimeType = data.mimeType || 'jpeg';
|
|
173
|
+
|
|
174
|
+
if (!base64Data) {
|
|
175
|
+
removeDebugImage(nodeId);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const nodeElement = document.getElementById(nodeId);
|
|
180
|
+
if (!nodeElement) return;
|
|
181
|
+
|
|
182
|
+
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
183
|
+
|
|
184
|
+
if (!debugContainer) {
|
|
185
|
+
// Create SVG foreignObject to embed HTML content in SVG
|
|
186
|
+
debugContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
187
|
+
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
188
|
+
debugContainer.setAttribute('x', '70');
|
|
189
|
+
debugContainer.setAttribute('y', '5');
|
|
190
|
+
debugContainer.setAttribute('width', '120');
|
|
191
|
+
debugContainer.setAttribute('height', '120');
|
|
192
|
+
debugContainer.style.overflow = 'visible';
|
|
193
|
+
|
|
194
|
+
// Create simple image directly inside foreignObject
|
|
195
|
+
const img = document.createElement('img');
|
|
196
|
+
img.id = 'debug-img-' + nodeId;
|
|
197
|
+
img.style.width = '100%';
|
|
198
|
+
img.style.height = 'auto';
|
|
199
|
+
img.style.display = 'block';
|
|
200
|
+
img.style.cursor = 'pointer';
|
|
201
|
+
img.style.maxHeight = '100px';
|
|
202
|
+
img.style.maxWidth = '100px';
|
|
203
|
+
|
|
204
|
+
img.onclick = function() {
|
|
205
|
+
removeDebugImage(nodeId);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
debugContainer.appendChild(img);
|
|
209
|
+
nodeElement.appendChild(debugContainer);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const img = document.getElementById('debug-img-' + nodeId);
|
|
213
|
+
|
|
214
|
+
if (img) {
|
|
215
|
+
img.src = `data:image/${mimeType};base64,${base64Data}`;
|
|
216
|
+
img.title = 'Debug image (click to hide)';
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function removeDebugImage(nodeId) {
|
|
221
|
+
const debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
222
|
+
if (debugContainer) {
|
|
223
|
+
debugContainer.remove();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function initializeWhenReady() {
|
|
228
|
+
if (typeof RED !== 'undefined' && RED.comms) {
|
|
229
|
+
subscribeToDebugImages();
|
|
230
|
+
|
|
231
|
+
// Clean up orphaned debug images periodically
|
|
232
|
+
setInterval(function() {
|
|
233
|
+
const debugContainers = document.querySelectorAll('[id^="debug-img-container-"]');
|
|
234
|
+
debugContainers.forEach(container => {
|
|
235
|
+
const nodeId = container.id.replace('debug-img-container-', '');
|
|
236
|
+
const nodeElement = document.getElementById(nodeId);
|
|
237
|
+
if (!nodeElement) {
|
|
238
|
+
container.remove();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}, 5000);
|
|
242
|
+
} else {
|
|
243
|
+
setTimeout(initializeWhenReady, 100);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (document.readyState === 'loading') {
|
|
248
|
+
document.addEventListener('DOMContentLoaded', initializeWhenReady);
|
|
249
|
+
} else {
|
|
250
|
+
initializeWhenReady();
|
|
251
|
+
}
|
|
252
|
+
})();
|
|
253
|
+
}
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<script type="text/x-red" data-template-name="filter">
|
|
257
|
+
<div class="form-row">
|
|
258
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
259
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<hr>
|
|
263
|
+
|
|
264
|
+
<!-- STANDARD I/O SECTION (same as all other nodes) -->
|
|
265
|
+
<div class="form-row">
|
|
266
|
+
<label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input from</label>
|
|
267
|
+
<input type="text" id="node-input-inputPath" style="width: 70%;">
|
|
268
|
+
<input type="hidden" id="node-input-inputPathType">
|
|
269
|
+
</div>
|
|
270
|
+
<div class="form-row">
|
|
271
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
272
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
273
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
274
|
+
</div>
|
|
275
|
+
<div class="form-row">
|
|
276
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
277
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
278
|
+
<option value="raw">Raw (fastest)</option>
|
|
279
|
+
<option value="jpg">JPEG</option>
|
|
280
|
+
<option value="png">PNG</option>
|
|
281
|
+
<option value="webp">WebP</option>
|
|
282
|
+
</select>
|
|
283
|
+
</div>
|
|
284
|
+
<div class="form-row" id="quality-row">
|
|
285
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
286
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
287
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
288
|
+
</div>
|
|
289
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
290
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
291
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
292
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
<!-- Debug Configuration -->
|
|
296
|
+
<div class="form-row">
|
|
297
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
298
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
299
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
300
|
+
</div>
|
|
301
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
302
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
303
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
304
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
305
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<hr>
|
|
309
|
+
|
|
310
|
+
<!-- FILTER-SPECIFIC SECTION -->
|
|
311
|
+
<div class="form-row">
|
|
312
|
+
<label for="node-input-filterType"><i class="fa fa-magic"></i> Filter Type</label>
|
|
313
|
+
<select id="node-input-filterType" style="width: 70%;">
|
|
314
|
+
<option value="blur">Blur</option>
|
|
315
|
+
<option value="sharpen">Sharpening</option>
|
|
316
|
+
<option value="edge">Edge Detection</option>
|
|
317
|
+
<option value="emboss">Emboss</option>
|
|
318
|
+
<option value="gaussian">Gaussian Blur</option>
|
|
319
|
+
</select>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
<div class="form-row" id="kernel-size-row">
|
|
323
|
+
<label for="node-input-kernelSize"><i class="fa fa-th"></i> Kernel Size</label>
|
|
324
|
+
<input type="text" id="node-input-kernelSize" style="width: 70%;" placeholder="3, 5, 7, 9, 11, 13, 15">
|
|
325
|
+
<input type="hidden" id="node-input-kernelSizeType">
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<div class="form-row" id="intensity-row">
|
|
329
|
+
<label for="node-input-intensity" id="intensity-label"><i class="fa fa-sliders"></i> Intensity</label>
|
|
330
|
+
<input type="text" id="node-input-intensity" style="width: 70%;" placeholder="0.0 - 2.0">
|
|
331
|
+
<input type="hidden" id="node-input-intensityType">
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<div class="form-tips">
|
|
335
|
+
<b>Tips:</b>
|
|
336
|
+
<ul>
|
|
337
|
+
<li><b>Kernel Size:</b> Must be odd (3, 5, 7, etc.). Larger sizes create stronger effects.</li>
|
|
338
|
+
<li><b>Intensity:</b> 0.0 = no effect, 1.0 = normal, 2.0 = maximum effect.</li>
|
|
339
|
+
<li>All parameters support dynamic values from <code>msg</code>, <code>flow</code>, or <code>global</code> context.</li>
|
|
340
|
+
</ul>
|
|
341
|
+
</div>
|
|
342
|
+
</script>
|
|
343
|
+
|
|
344
|
+
<script type="text/x-red" data-help-name="filter">
|
|
345
|
+
<p>The <strong>filter</strong> node applies professional image processing kernels including blur, sharpening, edge detection, emboss, and Gaussian blur effects. It provides configurable parameters and supports both single images and arrays with high-performance C++ backend processing using OpenCV.</p>
|
|
346
|
+
|
|
347
|
+
<h3>Details</h3>
|
|
348
|
+
<p>This node implements various convolution-based image processing operations with precise parameter control. Each filter type uses optimized OpenCV algorithms for maximum performance while maintaining image quality. The node supports dynamic parameter adjustment and multiple output formats, making it suitable for both real-time processing and batch operations.</p>
|
|
349
|
+
|
|
350
|
+
<h3>Properties</h3>
|
|
351
|
+
<dl class="message-properties">
|
|
352
|
+
<dt>Name <span class="property-type">string</span></dt>
|
|
353
|
+
<dd>Optional display name for the node</dd>
|
|
354
|
+
|
|
355
|
+
<dt>Input from <span class="property-type">msg | flow | global</span></dt>
|
|
356
|
+
<dd>Source path for image data (default: <code>msg.payload</code>)</dd>
|
|
357
|
+
|
|
358
|
+
<dt>Output to <span class="property-type">msg | flow | global</span></dt>
|
|
359
|
+
<dd>Destination path for processed image (default: <code>msg.payload</code>)</dd>
|
|
360
|
+
|
|
361
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
362
|
+
<dd>Image output format: <code>raw</code>, <code>jpg</code>, <code>png</code>, or <code>webp</code></dd>
|
|
363
|
+
|
|
364
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
365
|
+
<dd>Compression quality 1-100 for JPEG and WebP formats</dd>
|
|
366
|
+
|
|
367
|
+
<dt>Filter Type <span class="property-type">string</span></dt>
|
|
368
|
+
<dd>Processing algorithm: <code>blur</code>, <code>sharpen</code>, <code>edge</code>, <code>emboss</code>, or <code>gaussian</code></dd>
|
|
369
|
+
|
|
370
|
+
<dt>Kernel Size <span class="property-type">number | msg | flow | global</span></dt>
|
|
371
|
+
<dd>Convolution kernel size (3, 5, 7, 9, 11, 13, 15). Must be odd numbers</dd>
|
|
372
|
+
|
|
373
|
+
<dt>Intensity <span class="property-type">number | msg | flow | global</span></dt>
|
|
374
|
+
<dd>Effect strength (0.0-2.0). 0.0=no effect, 1.0=normal, 2.0=maximum</dd>
|
|
375
|
+
</dl>
|
|
376
|
+
|
|
377
|
+
<h3>Inputs</h3>
|
|
378
|
+
<dl class="message-properties">
|
|
379
|
+
<dt>payload <span class="property-type">object | array</span></dt>
|
|
380
|
+
<dd>Image object(s) in standard format:
|
|
381
|
+
<pre>{
|
|
382
|
+
data: Buffer, // Raw pixel data or file buffer
|
|
383
|
+
width: number, // Image width in pixels
|
|
384
|
+
height: number, // Image height in pixels
|
|
385
|
+
channels: number, // Channel count (1, 3, 4)
|
|
386
|
+
colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
|
|
387
|
+
dtype: string // "uint8", "uint16", "float32"
|
|
388
|
+
}</pre>
|
|
389
|
+
</dd>
|
|
390
|
+
<dt>filter parameters <span class="property-type">number</span></dt>
|
|
391
|
+
<dd>When parameters use dynamic sources, values are read from specified paths</dd>
|
|
392
|
+
</dl>
|
|
393
|
+
|
|
394
|
+
<h3>Outputs</h3>
|
|
395
|
+
<dl class="message-properties">
|
|
396
|
+
<dt>payload <span class="property-type">object | array | Buffer</span></dt>
|
|
397
|
+
<dd>Processed image(s) with filter applied. Format depends on Output Format setting</dd>
|
|
398
|
+
|
|
399
|
+
<dt>Raw format output</dt>
|
|
400
|
+
<dd>Image object with processed pixel data:
|
|
401
|
+
<pre>{
|
|
402
|
+
data: Buffer, // Filtered image data
|
|
403
|
+
width: number, // Unchanged from input
|
|
404
|
+
height: number, // Unchanged from input
|
|
405
|
+
channels: number, // Unchanged from input
|
|
406
|
+
colorSpace: string, // Unchanged from input
|
|
407
|
+
dtype: string // Unchanged from input
|
|
408
|
+
}</pre>
|
|
409
|
+
</dd>
|
|
410
|
+
|
|
411
|
+
<dt>Encoded format output</dt>
|
|
412
|
+
<dd>Compressed image buffer (JPEG/PNG/WebP) ready for storage or transmission</dd>
|
|
413
|
+
</dl>
|
|
414
|
+
|
|
415
|
+
<h3>Filter Types</h3>
|
|
416
|
+
<h4>Blur</h4>
|
|
417
|
+
<ul>
|
|
418
|
+
<li><strong>Algorithm:</strong> Box blur convolution for uniform smoothing</li>
|
|
419
|
+
<li><strong>Use Cases:</strong> Noise reduction, motion blur simulation, general smoothing</li>
|
|
420
|
+
<li><strong>Kernel Size:</strong> 3-15 (larger = more blur)</li>
|
|
421
|
+
<li><strong>Intensity:</strong> 0.0-2.0 (controls blur strength)</li>
|
|
422
|
+
</ul>
|
|
423
|
+
|
|
424
|
+
<h4>Sharpening</h4>
|
|
425
|
+
<ul>
|
|
426
|
+
<li><strong>Algorithm:</strong> Unsharp mask technique to enhance edges and details</li>
|
|
427
|
+
<li><strong>Use Cases:</strong> Photo enhancement, detail restoration, edge enhancement</li>
|
|
428
|
+
<li><strong>Kernel Size:</strong> 3-15 (affects sharpening area)</li>
|
|
429
|
+
<li><strong>Intensity:</strong> 0.0-2.0 (controls sharpening strength)</li>
|
|
430
|
+
</ul>
|
|
431
|
+
|
|
432
|
+
<h4>Edge Detection</h4>
|
|
433
|
+
<ul>
|
|
434
|
+
<li><strong>Algorithm:</strong> Sobel operator for gradient-based edge detection</li>
|
|
435
|
+
<li><strong>Use Cases:</strong> Object detection, boundary identification, preprocessing for analysis</li>
|
|
436
|
+
<li><strong>Kernel Size:</strong> 3-15 (affects edge sensitivity)</li>
|
|
437
|
+
<li><strong>Intensity:</strong> 0.0-2.0 (controls edge prominence)</li>
|
|
438
|
+
</ul>
|
|
439
|
+
|
|
440
|
+
<h4>Emboss</h4>
|
|
441
|
+
<ul>
|
|
442
|
+
<li><strong>Algorithm:</strong> Directional convolution creating 3D embossed appearance</li>
|
|
443
|
+
<li><strong>Use Cases:</strong> Artistic effects, texture enhancement, relief mapping</li>
|
|
444
|
+
<li><strong>Kernel Size:</strong> Fixed 3x3 (parameter hidden in UI)</li>
|
|
445
|
+
<li><strong>Intensity:</strong> 0.0-2.0 (controls emboss depth)</li>
|
|
446
|
+
</ul>
|
|
447
|
+
|
|
448
|
+
<h4>Gaussian Blur</h4>
|
|
449
|
+
<ul>
|
|
450
|
+
<li><strong>Algorithm:</strong> Gaussian distribution-based blur for natural smoothing</li>
|
|
451
|
+
<li><strong>Use Cases:</strong> Background blur, depth of field effects, anti-aliasing</li>
|
|
452
|
+
<li><strong>Kernel Size:</strong> 3-15 (affects blur radius)</li>
|
|
453
|
+
<li><strong>Intensity:</strong> 0.0-2.0 (controls sigma value)</li>
|
|
454
|
+
</ul>
|
|
455
|
+
|
|
456
|
+
<h3>Parameter Behavior</h3>
|
|
457
|
+
<h4>Kernel Size Constraints</h4>
|
|
458
|
+
<ul>
|
|
459
|
+
<li><strong>Valid Values:</strong> 3, 5, 7, 9, 11, 13, 15 (odd numbers only)</li>
|
|
460
|
+
<li><strong>Automatic Correction:</strong> Even numbers rounded to nearest odd</li>
|
|
461
|
+
<li><strong>Range Limits:</strong> Values <3 set to 3, values >15 set to 15</li>
|
|
462
|
+
<li><strong>Performance Impact:</strong> Larger kernels require more computation</li>
|
|
463
|
+
</ul>
|
|
464
|
+
|
|
465
|
+
<h4>Intensity Scaling</h4>
|
|
466
|
+
<ul>
|
|
467
|
+
<li><strong>Range:</strong> 0.0 (no effect) to 2.0 (maximum effect)</li>
|
|
468
|
+
<li><strong>Default:</strong> 1.0 (standard effect strength)</li>
|
|
469
|
+
<li><strong>Clamping:</strong> Values <0.0 set to 0.0, values >2.0 set to 2.0</li>
|
|
470
|
+
<li><strong>Linear Scaling:</strong> Effect strength scales linearly with intensity</li>
|
|
471
|
+
</ul>
|
|
472
|
+
|
|
473
|
+
<h4>Dynamic Parameters</h4>
|
|
474
|
+
<ul>
|
|
475
|
+
<li><strong>Runtime Updates:</strong> Parameters can be modified per message</li>
|
|
476
|
+
<li><strong>Type Validation:</strong> Non-numeric values trigger warnings</li>
|
|
477
|
+
<li><strong>Missing Values:</strong> Use node configuration defaults</li>
|
|
478
|
+
<li><strong>Array Processing:</strong> Same parameters applied to all images in array</li>
|
|
479
|
+
</ul>
|
|
480
|
+
|
|
481
|
+
<h3>Examples</h3>
|
|
482
|
+
<h4>Photo Enhancement</h4>
|
|
483
|
+
<pre>// Sharpen a photo with moderate strength
|
|
484
|
+
{
|
|
485
|
+
filterType: "sharpen",
|
|
486
|
+
kernelSize: 5,
|
|
487
|
+
intensity: 1.2
|
|
488
|
+
}</pre>
|
|
489
|
+
|
|
490
|
+
<h4>Background Blur</h4>
|
|
491
|
+
<pre>// Create shallow depth of field effect
|
|
492
|
+
{
|
|
493
|
+
filterType: "gaussian",
|
|
494
|
+
kernelSize: 9,
|
|
495
|
+
intensity: 1.5
|
|
496
|
+
}</pre>
|
|
497
|
+
|
|
498
|
+
<h4>Edge Detection</h4>
|
|
499
|
+
<pre>// Detect edges for computer vision preprocessing
|
|
500
|
+
{
|
|
501
|
+
filterType: "edge",
|
|
502
|
+
kernelSize: 3,
|
|
503
|
+
intensity: 1.0
|
|
504
|
+
}</pre>
|
|
505
|
+
|
|
506
|
+
<h4>Dynamic Filter Selection</h4>
|
|
507
|
+
<pre>// Use message properties for adaptive filtering
|
|
508
|
+
msg.filterIntensity = 0.8;
|
|
509
|
+
msg.blurAmount = 7;
|
|
510
|
+
// Configure node: intensity from msg.filterIntensity, kernelSize from msg.blurAmount</pre>
|
|
511
|
+
|
|
512
|
+
<h4>Artistic Effects</h4>
|
|
513
|
+
<pre>// Create embossed relief effect
|
|
514
|
+
{
|
|
515
|
+
filterType: "emboss",
|
|
516
|
+
intensity: 1.8
|
|
517
|
+
}</pre>
|
|
518
|
+
|
|
519
|
+
<h3>Node Interactions</h3>
|
|
520
|
+
<h4>Pre-Processing Chain</h4>
|
|
521
|
+
<ul>
|
|
522
|
+
<li><strong>image-in → resize → filter:</strong> Scale then apply effects</li>
|
|
523
|
+
<li><strong>crop → filter → padding:</strong> Extract region, apply effect, add border</li>
|
|
524
|
+
<li><strong>array-select → filter:</strong> Apply effects to selected images</li>
|
|
525
|
+
</ul>
|
|
526
|
+
|
|
527
|
+
<h4>Post-Processing Chain</h4>
|
|
528
|
+
<ul>
|
|
529
|
+
<li><strong>filter → filter:</strong> Stack multiple effects (e.g., blur then sharpen)</li>
|
|
530
|
+
<li><strong>filter → concat:</strong> Apply effects then combine images</li>
|
|
531
|
+
<li><strong>filter → array-out:</strong> Process then encode for output</li>
|
|
532
|
+
</ul>
|
|
533
|
+
|
|
534
|
+
<h4>Common Workflows</h4>
|
|
535
|
+
<ul>
|
|
536
|
+
<li><strong>Photo Processing:</strong> resize → filter (sharpen) → array-out</li>
|
|
537
|
+
<li><strong>Computer Vision:</strong> filter (edge) → analysis processing</li>
|
|
538
|
+
<li><strong>Creative Effects:</strong> filter (emboss) → filter (blur) → mosaic</li>
|
|
539
|
+
<li><strong>Noise Reduction:</strong> filter (gaussian) → filter (sharpen) → output</li>
|
|
540
|
+
</ul>
|
|
541
|
+
|
|
542
|
+
<h3>Output Formats</h3>
|
|
543
|
+
<dl class="message-properties">
|
|
544
|
+
<dt>raw <span class="property-type">object</span></dt>
|
|
545
|
+
<dd>Fastest option. Returns processed image object for further Node-RED processing</dd>
|
|
546
|
+
|
|
547
|
+
<dt>jpg <span class="property-type">Buffer</span></dt>
|
|
548
|
+
<dd>JPEG-compressed buffer with configurable quality (1-100). Good for photographs</dd>
|
|
549
|
+
|
|
550
|
+
<dt>png <span class="property-type">Buffer</span></dt>
|
|
551
|
+
<dd>PNG-compressed buffer with lossless compression. Preserves fine details from filtering</dd>
|
|
552
|
+
|
|
553
|
+
<dt>webp <span class="property-type">Buffer</span></dt>
|
|
554
|
+
<dd>WebP-compressed buffer with configurable quality. Modern format with excellent compression</dd>
|
|
555
|
+
</dl>
|
|
556
|
+
|
|
557
|
+
<h3>Error Handling</h3>
|
|
558
|
+
<ul>
|
|
559
|
+
<li><strong>Invalid Input:</strong> Non-image objects trigger warnings and prevent processing</li>
|
|
560
|
+
<li><strong>Parameter Validation:</strong> Invalid kernel sizes or intensities are corrected with warnings</li>
|
|
561
|
+
<li><strong>Missing Properties:</strong> Incomplete image objects are rejected with detailed error messages</li>
|
|
562
|
+
<li><strong>Unsupported Formats:</strong> Incompatible image data types trigger conversion attempts</li>
|
|
563
|
+
<li><strong>Memory Limits:</strong> Large images with large kernels may fail with memory errors</li>
|
|
564
|
+
<li><strong>Dynamic Values:</strong> Missing or invalid dynamic values fall back to node defaults</li>
|
|
565
|
+
</ul>
|
|
566
|
+
|
|
567
|
+
<h3>Performance</h3>
|
|
568
|
+
<ul>
|
|
569
|
+
<li><strong>C++ Backend:</strong> Optimized OpenCV algorithms for maximum performance</li>
|
|
570
|
+
<li><strong>Array Support:</strong> Parallel processing of image arrays using Promise.all()</li>
|
|
571
|
+
<li><strong>Memory Efficiency:</strong> In-place processing where possible to minimize memory usage</li>
|
|
572
|
+
<li><strong>Status Display:</strong> Real-time timing information (conversion, processing, encoding)</li>
|
|
573
|
+
<li><strong>Algorithm Optimization:</strong> SIMD instructions and multi-threading where supported</li>
|
|
574
|
+
<li><strong>Performance Metrics:</strong> Processing speed varies by filter: blur/gaussian ~1ms/MP, edge/emboss ~2ms/MP</li>
|
|
575
|
+
</ul>
|
|
576
|
+
|
|
577
|
+
<p><strong>Note:</strong> The node status bar displays detailed timing information: conversion time (input processing) + task time (filtering operation) + encoding time (output formatting). Filter performance varies significantly based on kernel size and image complexity.</p>
|
|
578
|
+
</script>
|