@rosepetal/node-red-contrib-image-tools 1.2.2 → 1.2.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/node-red-contrib-image-tools/lib/node-utils.js +64 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +23 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +8 -2
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +24 -1
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +13 -7
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +23 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +8 -2
- package/node-red-contrib-image-tools/nodes/blend/blend.html +24 -1
- package/node-red-contrib-image-tools/nodes/blend/blend.js +8 -2
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +23 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +9 -3
- package/node-red-contrib-image-tools/nodes/mix/concat.html +24 -1
- package/node-red-contrib-image-tools/nodes/mix/concat.js +8 -2
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +23 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +8 -2
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +24 -1
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +9 -1
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +25 -2
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +7 -1
- package/node-red-contrib-image-tools/nodes/transform/color-convert.html +25 -1
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +9 -1
- package/node-red-contrib-image-tools/nodes/transform/crop.html +25 -1
- package/node-red-contrib-image-tools/nodes/transform/crop.js +9 -1
- package/node-red-contrib-image-tools/nodes/transform/draw.html +24 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.js +8 -2
- package/node-red-contrib-image-tools/nodes/transform/filter.html +25 -1
- package/node-red-contrib-image-tools/nodes/transform/filter.js +9 -1
- package/node-red-contrib-image-tools/nodes/transform/padding.html +25 -1
- package/node-red-contrib-image-tools/nodes/transform/padding.js +9 -1
- package/node-red-contrib-image-tools/nodes/transform/resize.html +26 -2
- package/node-red-contrib-image-tools/nodes/transform/resize.js +9 -1
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +25 -1
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +9 -1
- package/package.json +1 -1
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
outputFormat:{value:"raw"},
|
|
17
17
|
outputQuality:{value:90},
|
|
18
18
|
pngOptimize:{value:false},
|
|
19
|
-
|
|
19
|
+
webpLossless:{value:false},
|
|
20
|
+
webpSmartSubsample:{value:false},
|
|
21
|
+
webpEffort:{value:""},
|
|
22
|
+
|
|
20
23
|
// Filtering options
|
|
21
24
|
minConfidence:{value:0.5},
|
|
22
25
|
minConfidenceType:{value:"num"},
|
|
@@ -72,6 +75,11 @@
|
|
|
72
75
|
$('#quality-row').hide();
|
|
73
76
|
}
|
|
74
77
|
$('#png-optimize-row').toggle(format === 'png');
|
|
78
|
+
// Show WebP advanced options only when WebP is selected
|
|
79
|
+
const isWebp = format === 'webp';
|
|
80
|
+
$('#webp-lossless-row').toggle(isWebp);
|
|
81
|
+
$('#webp-smartsubsample-row').toggle(isWebp);
|
|
82
|
+
$('#webp-effort-row').toggle(isWebp);
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
$('#node-input-outputFormat').on('change', updateQualityVisibility);
|
|
@@ -137,6 +145,21 @@
|
|
|
137
145
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
138
146
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
139
147
|
</div>
|
|
148
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
149
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
150
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
151
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
154
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
155
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
156
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
159
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
160
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
161
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
162
|
+
</div>
|
|
140
163
|
|
|
141
164
|
<!-- Debug Configuration -->
|
|
142
165
|
<div class="form-row">
|
|
@@ -29,6 +29,8 @@ module.exports = function (RED) {
|
|
|
29
29
|
const outputFormat = config.outputFormat || 'raw';
|
|
30
30
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
31
31
|
const pngOptimize = config.pngOptimize || false;
|
|
32
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
33
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
32
34
|
const minConfidence = NodeUtils.resolveDimension(node, config.minConfidenceType, config.minConfidence, msg) || 0.5;
|
|
33
35
|
|
|
34
36
|
/* Get input data */
|
|
@@ -162,7 +164,7 @@ module.exports = function (RED) {
|
|
|
162
164
|
// Convert bbox coordinates to crop parameters
|
|
163
165
|
const { x, y, width, height, label, confidence, originalBbox } = bbox;
|
|
164
166
|
|
|
165
|
-
return CppProcessor.crop(image, x, y, width, height, false,
|
|
167
|
+
return CppProcessor.crop(image, x, y, width, height, false, cppFormat, outputQuality, pngOptimize)
|
|
166
168
|
.then(result => ({
|
|
167
169
|
...result.image, // Spread image properties (data, width, height, channels, colorSpace, dtype)
|
|
168
170
|
tag: label, // Add tag metadata directly
|
|
@@ -187,6 +189,12 @@ module.exports = function (RED) {
|
|
|
187
189
|
allCrops.push(cropWithMetadata);
|
|
188
190
|
});
|
|
189
191
|
|
|
192
|
+
if (useSharpWebp) {
|
|
193
|
+
for (let i = 0; i < allCrops.length; i++) {
|
|
194
|
+
allCrops[i] = await NodeUtils.encodeWebpAdvanced(allCrops[i], config);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
190
198
|
/* Set output */
|
|
191
199
|
RED.util.setMessageProperty(msg, outputPath, allCrops);
|
|
192
200
|
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
outputFormat: { value: "raw" },
|
|
15
15
|
outputQuality: { value: 90 },
|
|
16
16
|
pngOptimize: { value: false },
|
|
17
|
+
webpLossless: { value: false },
|
|
18
|
+
webpSmartSubsample: { value: false },
|
|
19
|
+
webpEffort: { value: "" },
|
|
17
20
|
// Debug configuration
|
|
18
21
|
debugEnabled: { value: false },
|
|
19
22
|
debugWidth: { value: 200 },
|
|
@@ -94,12 +97,17 @@
|
|
|
94
97
|
} else {
|
|
95
98
|
$('#quality-row').hide();
|
|
96
99
|
}
|
|
97
|
-
|
|
100
|
+
|
|
98
101
|
if (format === 'png') {
|
|
99
102
|
$('#png-optimize-row').show();
|
|
100
103
|
} else {
|
|
101
104
|
$('#png-optimize-row').hide();
|
|
102
105
|
}
|
|
106
|
+
// Show WebP advanced options only when WebP is selected
|
|
107
|
+
const isWebp = format === 'webp';
|
|
108
|
+
$('#webp-lossless-row').toggle(isWebp);
|
|
109
|
+
$('#webp-smartsubsample-row').toggle(isWebp);
|
|
110
|
+
$('#webp-effort-row').toggle(isWebp);
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
$('#node-input-outputFormat').on('change', updateQualityVisibility);
|
|
@@ -329,7 +337,22 @@
|
|
|
329
337
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
330
338
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
331
339
|
</div>
|
|
332
|
-
|
|
340
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
341
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
342
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
343
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
344
|
+
</div>
|
|
345
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
346
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
347
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
348
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
349
|
+
</div>
|
|
350
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
351
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
352
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
353
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
354
|
+
</div>
|
|
355
|
+
|
|
333
356
|
<!-- Return Matrix Option -->
|
|
334
357
|
<div class="form-row">
|
|
335
358
|
<label for="node-input-returnMatrix"><i class="fa fa-calculator"></i> Transform Matrix</label>
|
|
@@ -63,6 +63,8 @@ module.exports = function (RED) {
|
|
|
63
63
|
const outputFormat = config.outputFormat || 'raw';
|
|
64
64
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
65
65
|
const pngOptimize = config.pngOptimize || false;
|
|
66
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
67
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
66
68
|
const preset = config.preset || 'ultra-fast';
|
|
67
69
|
const returnMatrix = config.returnMatrix || false;
|
|
68
70
|
const transformPolygon = config.transformPolygon || false;
|
|
@@ -250,13 +252,17 @@ module.exports = function (RED) {
|
|
|
250
252
|
scale,
|
|
251
253
|
maxIterations,
|
|
252
254
|
terminationEps,
|
|
253
|
-
|
|
255
|
+
cppFormat,
|
|
254
256
|
outputQuality,
|
|
255
257
|
pngOptimize,
|
|
256
258
|
returnMatrix,
|
|
257
259
|
polygon
|
|
258
260
|
);
|
|
259
261
|
|
|
262
|
+
if (useSharpWebp) {
|
|
263
|
+
result.image = await NodeUtils.encodeWebpAdvanced(result.image, config);
|
|
264
|
+
}
|
|
265
|
+
|
|
260
266
|
/* ▸ Status: standardized success formatting ----------------------- */
|
|
261
267
|
const total = performance.now() - startTime;
|
|
262
268
|
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
outputFormat : { value:"raw" },
|
|
12
12
|
outputQuality : { value:90 },
|
|
13
13
|
pngOptimize : { value:false },
|
|
14
|
+
webpLossless : { value:false },
|
|
15
|
+
webpSmartSubsample : { value:false },
|
|
16
|
+
webpEffort : { value:"" },
|
|
14
17
|
// Debug configuration
|
|
15
18
|
debugEnabled : { value:false },
|
|
16
19
|
debugWidth : { value:200 },
|
|
@@ -18,7 +21,7 @@
|
|
|
18
21
|
targetColorSpace: { value:"RGB" }
|
|
19
22
|
},
|
|
20
23
|
inputs :1, outputs:1,
|
|
21
|
-
icon:"font-awesome/fa-
|
|
24
|
+
icon:"font-awesome/fa-eyedropper",
|
|
22
25
|
label:function(){ return this.name || "color-convert"; },
|
|
23
26
|
|
|
24
27
|
oneditprepare:function(){
|
|
@@ -29,6 +32,12 @@
|
|
|
29
32
|
const format = $("#node-input-outputFormat").val();
|
|
30
33
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
31
34
|
$("#png-optimize-row").toggle(format === "png");
|
|
35
|
+
|
|
36
|
+
// Show WebP advanced options only when WebP is selected
|
|
37
|
+
const isWebp = format === "webp";
|
|
38
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
39
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
40
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
32
41
|
}
|
|
33
42
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
34
43
|
updateQualityVisibility(); // initial state
|
|
@@ -90,6 +99,21 @@
|
|
|
90
99
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
91
100
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
92
101
|
</div>
|
|
102
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
103
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
104
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
105
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
108
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
109
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
110
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
111
|
+
</div>
|
|
112
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
113
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
114
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
115
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
116
|
+
</div>
|
|
93
117
|
|
|
94
118
|
<!-- Debug Configuration -->
|
|
95
119
|
<div class="form-row">
|
|
@@ -42,6 +42,8 @@ module.exports = function (RED) {
|
|
|
42
42
|
const outputFormat = config.outputFormat || 'raw';
|
|
43
43
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
44
44
|
const pngOptimize = config.pngOptimize || false;
|
|
45
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
46
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
45
47
|
const targetColorSpace = config.targetColorSpace || 'RGB';
|
|
46
48
|
|
|
47
49
|
// Validate input images with error passthrough
|
|
@@ -65,7 +67,7 @@ module.exports = function (RED) {
|
|
|
65
67
|
|
|
66
68
|
/* ——— launch conversions in parallel ——— */
|
|
67
69
|
const promises = imgs.map(img =>
|
|
68
|
-
CppProcessor.colorConvert(img, targetColorSpace,
|
|
70
|
+
CppProcessor.colorConvert(img, targetColorSpace, cppFormat, outputQuality, pngOptimize)
|
|
69
71
|
);
|
|
70
72
|
|
|
71
73
|
const results = await Promise.all(promises);
|
|
@@ -80,6 +82,12 @@ module.exports = function (RED) {
|
|
|
80
82
|
return acc;
|
|
81
83
|
}, { totalConvertMs: 0, totalTaskMs: 0, encodeMs: 0, images: [] });
|
|
82
84
|
|
|
85
|
+
if (useSharpWebp) {
|
|
86
|
+
for (let i = 0; i < images.length; i++) {
|
|
87
|
+
images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
83
91
|
const out = Array.isArray(originalPayload) ? images : images[0];
|
|
84
92
|
const durMs = performance.now() - t0;
|
|
85
93
|
|
|
@@ -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},
|
|
@@ -68,6 +71,12 @@
|
|
|
68
71
|
const format = $("#node-input-outputFormat").val();
|
|
69
72
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
70
73
|
$("#png-optimize-row").toggle(format === "png");
|
|
74
|
+
|
|
75
|
+
// Show WebP advanced options only when WebP is selected
|
|
76
|
+
const isWebp = format === "webp";
|
|
77
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
78
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
79
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
71
80
|
}
|
|
72
81
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
73
82
|
updateQualityVisibility(); // initial state
|
|
@@ -256,7 +265,22 @@
|
|
|
256
265
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
257
266
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
258
267
|
</div>
|
|
259
|
-
|
|
268
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
269
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
270
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
271
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
272
|
+
</div>
|
|
273
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
274
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
275
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
276
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
277
|
+
</div>
|
|
278
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
279
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
280
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
281
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
260
284
|
<!-- Debug Configuration -->
|
|
261
285
|
<div class="form-row">
|
|
262
286
|
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
@@ -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
|
|
|
53
55
|
/* imagen o lista de imágenes */
|
|
54
56
|
const imgs = Array.isArray(originalPayload) ? originalPayload : [originalPayload];
|
|
@@ -77,7 +79,7 @@ module.exports = function (RED) {
|
|
|
77
79
|
|
|
78
80
|
/* lanzar recortes en paralelo */
|
|
79
81
|
const jobs = imgs.map(img =>
|
|
80
|
-
CppProcessor.crop(img, x, y, width, height, normalized,
|
|
82
|
+
CppProcessor.crop(img, x, y, width, height, normalized, cppFormat, outputQuality, pngOptimize)
|
|
81
83
|
);
|
|
82
84
|
|
|
83
85
|
const results = await Promise.all(jobs);
|
|
@@ -92,6 +94,12 @@ module.exports = function (RED) {
|
|
|
92
94
|
return acc;
|
|
93
95
|
}, { totalConvertMs: 0, totalTaskMs: 0, totalEncodeMs: 0, images: [] });
|
|
94
96
|
|
|
97
|
+
if (useSharpWebp) {
|
|
98
|
+
for (let i = 0; i < images.length; i++) {
|
|
99
|
+
images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
95
103
|
/* salida */
|
|
96
104
|
const out = Array.isArray(originalPayload) ? images : images[0];
|
|
97
105
|
NodeUtils.setOutputValue(node, msg, outputPath, outputPathType, out);
|
|
@@ -92,6 +92,9 @@
|
|
|
92
92
|
outputFormat: { value: "raw" },
|
|
93
93
|
outputQuality: { value: 90 },
|
|
94
94
|
pngOptimize: { value: false },
|
|
95
|
+
webpLossless: { value: false },
|
|
96
|
+
webpSmartSubsample: { value: false },
|
|
97
|
+
webpEffort: { value: "" },
|
|
95
98
|
debugEnabled: { value: false },
|
|
96
99
|
debugWidth: { value: 200 },
|
|
97
100
|
debugWidthType: { value: "num" },
|
|
@@ -130,6 +133,12 @@
|
|
|
130
133
|
const format = $('#node-input-outputFormat').val();
|
|
131
134
|
$('#quality-row').toggle(format === 'jpg' || format === 'webp');
|
|
132
135
|
$('#png-optimize-row').toggle(format === 'png');
|
|
136
|
+
|
|
137
|
+
// Show WebP advanced options only when WebP is selected
|
|
138
|
+
const isWebp = format === 'webp';
|
|
139
|
+
$('#webp-lossless-row').toggle(isWebp);
|
|
140
|
+
$('#webp-smartsubsample-row').toggle(isWebp);
|
|
141
|
+
$('#webp-effort-row').toggle(isWebp);
|
|
133
142
|
}
|
|
134
143
|
$('#node-input-outputFormat').on('change', function () {
|
|
135
144
|
updateQualityVisibility();
|
|
@@ -649,6 +658,21 @@
|
|
|
649
658
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
650
659
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG output</label>
|
|
651
660
|
</div>
|
|
661
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
662
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
663
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
664
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
665
|
+
</div>
|
|
666
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
667
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
668
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
669
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
670
|
+
</div>
|
|
671
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
672
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
673
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
674
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
675
|
+
</div>
|
|
652
676
|
|
|
653
677
|
<!-- Debug configuration -->
|
|
654
678
|
<div class="form-row">
|
|
@@ -44,6 +44,8 @@ module.exports = function (RED) {
|
|
|
44
44
|
const outputFormat = config.outputFormat || 'raw';
|
|
45
45
|
const outputQuality = parseInt(config.outputQuality, 10) || 90;
|
|
46
46
|
const pngOptimize = config.pngOptimize || false;
|
|
47
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
48
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
47
49
|
|
|
48
50
|
const baseImage = NodeUtils.validateImageStructure(originalPayload, node);
|
|
49
51
|
if (!baseImage) {
|
|
@@ -60,15 +62,19 @@ module.exports = function (RED) {
|
|
|
60
62
|
node.warn('No valid points or lines configured. Outputting original image.');
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
let { image: resultImage, timing = {} } = await CppProcessor.draw(
|
|
64
66
|
baseImage,
|
|
65
67
|
resolvedPoints,
|
|
66
68
|
resolvedLines,
|
|
67
|
-
|
|
69
|
+
cppFormat,
|
|
68
70
|
outputQuality,
|
|
69
71
|
pngOptimize
|
|
70
72
|
);
|
|
71
73
|
|
|
74
|
+
if (useSharpWebp) {
|
|
75
|
+
resultImage = await NodeUtils.encodeWebpAdvanced(resultImage, config);
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
NodeUtils.setOutputValue(node, msg, outputPath, outputPathType, resultImage);
|
|
73
79
|
|
|
74
80
|
const elapsed = performance.now() - startTime;
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
outputFormat: { value: "raw" },
|
|
13
13
|
outputQuality: { value: 90 },
|
|
14
14
|
pngOptimize: { value: false },
|
|
15
|
+
webpLossless: { value: false },
|
|
16
|
+
webpSmartSubsample: { value: false },
|
|
17
|
+
webpEffort: { value: "" },
|
|
15
18
|
// Debug configuration
|
|
16
19
|
debugEnabled: { value: false },
|
|
17
20
|
debugWidth: { value: 200 },
|
|
@@ -106,6 +109,12 @@
|
|
|
106
109
|
const format = $("#node-input-outputFormat").val();
|
|
107
110
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
108
111
|
$("#png-optimize-row").toggle(format === "png");
|
|
112
|
+
|
|
113
|
+
// Show WebP advanced options only when WebP is selected
|
|
114
|
+
const isWebp = format === "webp";
|
|
115
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
116
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
117
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
109
118
|
}
|
|
110
119
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
111
120
|
updateQualityVisibility(); // initial state
|
|
@@ -291,7 +300,22 @@
|
|
|
291
300
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
292
301
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
293
302
|
</div>
|
|
294
|
-
|
|
303
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
304
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
305
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
306
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
307
|
+
</div>
|
|
308
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
309
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
310
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
311
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
312
|
+
</div>
|
|
313
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
314
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
315
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
316
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
295
319
|
<!-- Debug Configuration -->
|
|
296
320
|
<div class="form-row">
|
|
297
321
|
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
@@ -45,6 +45,8 @@ module.exports = function (RED) {
|
|
|
45
45
|
const outputFormat = config.outputFormat || 'raw';
|
|
46
46
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
47
47
|
const pngOptimize = config.pngOptimize || false;
|
|
48
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
49
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
48
50
|
|
|
49
51
|
// Filter parameters
|
|
50
52
|
const filterType = config.filterType || 'blur';
|
|
@@ -97,7 +99,7 @@ module.exports = function (RED) {
|
|
|
97
99
|
filterType,
|
|
98
100
|
kernelSize,
|
|
99
101
|
intensity,
|
|
100
|
-
|
|
102
|
+
cppFormat,
|
|
101
103
|
outputQuality,
|
|
102
104
|
pngOptimize
|
|
103
105
|
);
|
|
@@ -118,6 +120,12 @@ module.exports = function (RED) {
|
|
|
118
120
|
{ totalConvertMs: 0, totalTaskMs: 0, encodeMs: 0, images: [] }
|
|
119
121
|
);
|
|
120
122
|
|
|
123
|
+
if (useSharpWebp) {
|
|
124
|
+
for (let i = 0; i < images.length; i++) {
|
|
125
|
+
images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
121
129
|
// Prepare output
|
|
122
130
|
const output = Array.isArray(originalPayload) ? images : images[0];
|
|
123
131
|
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
outputFormat:{value:"raw"},
|
|
14
14
|
outputQuality:{value:90},
|
|
15
15
|
pngOptimize:{value:false},
|
|
16
|
+
webpLossless:{value:false},
|
|
17
|
+
webpSmartSubsample:{value:false},
|
|
18
|
+
webpEffort:{value:""},
|
|
16
19
|
// Debug configuration
|
|
17
20
|
debugEnabled:{value:false},
|
|
18
21
|
debugWidth:{value:200},
|
|
@@ -54,6 +57,12 @@
|
|
|
54
57
|
const format = $("#node-input-outputFormat").val();
|
|
55
58
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
56
59
|
$("#png-optimize-row").toggle(format === "png");
|
|
60
|
+
|
|
61
|
+
// Show WebP advanced options only when WebP is selected
|
|
62
|
+
const isWebp = format === "webp";
|
|
63
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
64
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
65
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
57
66
|
}
|
|
58
67
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
59
68
|
updateQualityVisibility(); // initial state
|
|
@@ -239,7 +248,22 @@
|
|
|
239
248
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
240
249
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
241
250
|
</div>
|
|
242
|
-
|
|
251
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
252
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
253
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
254
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
255
|
+
</div>
|
|
256
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
257
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
258
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
259
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
260
|
+
</div>
|
|
261
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
262
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
263
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
264
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
243
267
|
<!-- Debug Configuration -->
|
|
244
268
|
<div class="form-row">
|
|
245
269
|
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
@@ -67,6 +67,8 @@ module.exports = function (RED) {
|
|
|
67
67
|
const outputFormat = cfg.outputFormat || 'raw';
|
|
68
68
|
const outputQuality = parseInt(cfg.outputQuality) || 90;
|
|
69
69
|
const pngOptimize = cfg.pngOptimize || false;
|
|
70
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(cfg);
|
|
71
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
70
72
|
const padHex = cfg.padColor || '#000000';
|
|
71
73
|
|
|
72
74
|
/* numeric margins can come from msg / flow / global */
|
|
@@ -77,7 +79,7 @@ module.exports = function (RED) {
|
|
|
77
79
|
|
|
78
80
|
/* one C++ call per image (fast, runs in parallel) */
|
|
79
81
|
const tasks = imgs.map(img =>
|
|
80
|
-
CppProcessor.padding(img, tVal, bVal, lVal, rVal, padHex,
|
|
82
|
+
CppProcessor.padding(img, tVal, bVal, lVal, rVal, padHex, cppFormat, outputQuality, pngOptimize)
|
|
81
83
|
);
|
|
82
84
|
const results = await Promise.all(tasks);
|
|
83
85
|
|
|
@@ -90,6 +92,12 @@ module.exports = function (RED) {
|
|
|
90
92
|
return r.image;
|
|
91
93
|
});
|
|
92
94
|
|
|
95
|
+
if (useSharpWebp) {
|
|
96
|
+
for (let i = 0; i < outImgs.length; i++) {
|
|
97
|
+
outImgs[i] = await NodeUtils.encodeWebpAdvanced(outImgs[i], cfg);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
93
101
|
NodeUtils.setOutputValue(node, msg, outPath, outputPathType, Array.isArray(originalPayload) ? outImgs : outImgs[0]);
|
|
94
102
|
|
|
95
103
|
// Debug image display
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
outputFormat: { value: "raw" },
|
|
13
13
|
outputQuality: { value: 90 },
|
|
14
14
|
pngOptimize: { value: false },
|
|
15
|
+
webpLossless: { value: false },
|
|
16
|
+
webpSmartSubsample: { value: false },
|
|
17
|
+
webpEffort: { value: "" },
|
|
15
18
|
// Debug configuration
|
|
16
19
|
debugEnabled: { value: false },
|
|
17
20
|
debugWidth: { value: 200 },
|
|
@@ -103,13 +106,19 @@
|
|
|
103
106
|
} else {
|
|
104
107
|
$('#quality-row').hide();
|
|
105
108
|
}
|
|
106
|
-
|
|
109
|
+
|
|
107
110
|
// Show PNG optimize checkbox only when PNG is selected
|
|
108
111
|
if (format === 'png') {
|
|
109
112
|
$('#png-optimize-row').show();
|
|
110
113
|
} else {
|
|
111
114
|
$('#png-optimize-row').hide();
|
|
112
115
|
}
|
|
116
|
+
|
|
117
|
+
// Show WebP advanced options only when WebP is selected
|
|
118
|
+
const isWebp = format === 'webp';
|
|
119
|
+
$('#webp-lossless-row').toggle(isWebp);
|
|
120
|
+
$('#webp-smartsubsample-row').toggle(isWebp);
|
|
121
|
+
$('#webp-effort-row').toggle(isWebp);
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
$('#node-input-outputFormat').on('change', updateQualityVisibility);
|
|
@@ -309,7 +318,22 @@
|
|
|
309
318
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
310
319
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
311
320
|
</div>
|
|
312
|
-
|
|
321
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
322
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
323
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
324
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
327
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
328
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
329
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
330
|
+
</div>
|
|
331
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
332
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
333
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
334
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
335
|
+
</div>
|
|
336
|
+
|
|
313
337
|
<!-- Debug Configuration -->
|
|
314
338
|
<div class="form-row">
|
|
315
339
|
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
@@ -44,6 +44,8 @@ module.exports = function (RED) {
|
|
|
44
44
|
const outputFormat = config.outputFormat || 'raw';
|
|
45
45
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
46
46
|
const pngOptimize = config.pngOptimize || false;
|
|
47
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
48
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
47
49
|
const inputList = Array.isArray(originalPayload)
|
|
48
50
|
? originalPayload
|
|
49
51
|
: [originalPayload];
|
|
@@ -93,7 +95,7 @@ module.exports = function (RED) {
|
|
|
93
95
|
inputImage,
|
|
94
96
|
config.widthMode, wVal,
|
|
95
97
|
config.heightMode, hVal,
|
|
96
|
-
|
|
98
|
+
cppFormat,
|
|
97
99
|
outputQuality,
|
|
98
100
|
pngOptimize
|
|
99
101
|
)
|
|
@@ -113,6 +115,12 @@ module.exports = function (RED) {
|
|
|
113
115
|
{ totalConvertMs: 0, totalTaskMs: 0, encodeMs: 0, images: [] }
|
|
114
116
|
);
|
|
115
117
|
|
|
118
|
+
if (useSharpWebp) {
|
|
119
|
+
for (let i = 0; i < images.length; i++) {
|
|
120
|
+
images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
const out = Array.isArray(originalPayload) ? images : images[0];
|
|
117
125
|
const elapsedTime = performance.now() - startTime;
|
|
118
126
|
|