@rosepetal/node-red-contrib-image-tools 1.2.0 → 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.
Files changed (48) hide show
  1. package/node-red-contrib-image-tools/lib/node-utils.js +64 -0
  2. package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +23 -0
  3. package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +8 -2
  4. package/node-red-contrib-image-tools/nodes/blend/add-mask.html +24 -1
  5. package/node-red-contrib-image-tools/nodes/blend/add-mask.js +13 -7
  6. package/node-red-contrib-image-tools/nodes/blend/add-masks.html +23 -0
  7. package/node-red-contrib-image-tools/nodes/blend/add-masks.js +8 -2
  8. package/node-red-contrib-image-tools/nodes/blend/blend.html +24 -1
  9. package/node-red-contrib-image-tools/nodes/blend/blend.js +8 -2
  10. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +23 -0
  11. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +9 -3
  12. package/node-red-contrib-image-tools/nodes/mix/concat.html +24 -1
  13. package/node-red-contrib-image-tools/nodes/mix/concat.js +8 -2
  14. package/node-red-contrib-image-tools/nodes/mix/mosaic.html +23 -0
  15. package/node-red-contrib-image-tools/nodes/mix/mosaic.js +8 -2
  16. package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +24 -1
  17. package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +9 -1
  18. package/node-red-contrib-image-tools/nodes/specialized/image-align.html +25 -2
  19. package/node-red-contrib-image-tools/nodes/specialized/image-align.js +7 -1
  20. package/node-red-contrib-image-tools/nodes/transform/color-convert.html +213 -0
  21. package/node-red-contrib-image-tools/nodes/transform/color-convert.js +161 -0
  22. package/node-red-contrib-image-tools/nodes/transform/crop.html +25 -1
  23. package/node-red-contrib-image-tools/nodes/transform/crop.js +9 -1
  24. package/node-red-contrib-image-tools/nodes/transform/draw.html +24 -0
  25. package/node-red-contrib-image-tools/nodes/transform/draw.js +8 -2
  26. package/node-red-contrib-image-tools/nodes/transform/filter.html +25 -1
  27. package/node-red-contrib-image-tools/nodes/transform/filter.js +9 -1
  28. package/node-red-contrib-image-tools/nodes/transform/padding.html +25 -1
  29. package/node-red-contrib-image-tools/nodes/transform/padding.js +9 -1
  30. package/node-red-contrib-image-tools/nodes/transform/resize.html +26 -2
  31. package/node-red-contrib-image-tools/nodes/transform/resize.js +9 -1
  32. package/node-red-contrib-image-tools/nodes/transform/rotate.html +30 -6
  33. package/node-red-contrib-image-tools/nodes/transform/rotate.js +9 -1
  34. package/node-red-contrib-image-tools/package.json +1 -0
  35. package/package.json +2 -1
  36. package/rosepetal-image-engine/binding.gyp +2 -1
  37. package/rosepetal-image-engine/src/advanced-mosaic.cpp +4 -4
  38. package/rosepetal-image-engine/src/color-convert.cpp +184 -0
  39. package/rosepetal-image-engine/src/concat.cpp +2 -2
  40. package/rosepetal-image-engine/src/crop.cpp +4 -4
  41. package/rosepetal-image-engine/src/filter.cpp +4 -4
  42. package/rosepetal-image-engine/src/image-align.cpp +1 -1
  43. package/rosepetal-image-engine/src/main.cpp +2 -0
  44. package/rosepetal-image-engine/src/mosaic.cpp +4 -4
  45. package/rosepetal-image-engine/src/padding.cpp +4 -4
  46. package/rosepetal-image-engine/src/resize.cpp +4 -4
  47. package/rosepetal-image-engine/src/rotate.cpp +6 -6
  48. package/rosepetal-image-engine/src/utils.h +2 -2
@@ -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
- const { image: resultImage, timing = {} } = await CppProcessor.draw(
65
+ let { image: resultImage, timing = {} } = await CppProcessor.draw(
64
66
  baseImage,
65
67
  resolvedPoints,
66
68
  resolvedLines,
67
- outputFormat,
69
+ cppFormat,
68
70
  outputQuality,
69
71
  pngOptimize
70
72
  );
71
73
 
74
+ if (useSharpWebp) {
75
+ resultImage = await NodeUtils.encodeWebpAdvanced(resultImage, config);
76
+ }
77
+
72
78
  NodeUtils.setOutputValue(node, msg, outputPath, outputPathType, resultImage);
73
79
 
74
80
  const elapsed = performance.now() - startTime;
@@ -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
- outputFormat,
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, outputFormat, outputQuality, pngOptimize)
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
- outputFormat,
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
 
@@ -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 },
@@ -32,6 +35,12 @@
32
35
  const format = $("#node-input-outputFormat").val();
33
36
  $("#quality-row").toggle(format === "jpg" || format === "webp");
34
37
  $("#png-optimize-row").toggle(format === "png");
38
+
39
+ // Show WebP advanced options only when WebP is selected
40
+ const isWebp = format === "webp";
41
+ $("#webp-lossless-row").toggle(isWebp);
42
+ $("#webp-smartsubsample-row").toggle(isWebp);
43
+ $("#webp-effort-row").toggle(isWebp);
35
44
  }
36
45
  $("#node-input-outputFormat").on("change", updateQualityVisibility);
37
46
  updateQualityVisibility(); // initial state
@@ -203,7 +212,22 @@
203
212
  <input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
204
213
  <label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
205
214
  </div>
206
-
215
+ <div class="form-row" id="webp-lossless-row" style="display: none;">
216
+ <label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
217
+ <input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
218
+ <label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
219
+ </div>
220
+ <div class="form-row" id="webp-smartsubsample-row" style="display: none;">
221
+ <label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
222
+ <input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
223
+ <label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
224
+ </div>
225
+ <div class="form-row" id="webp-effort-row" style="display: none;">
226
+ <label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
227
+ <input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
228
+ <span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
229
+ </div>
230
+
207
231
  <!-- Debug Configuration -->
208
232
  <div class="form-row">
209
233
  <label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
@@ -226,7 +250,7 @@
226
250
  <p>Rotates images by a specified angle with customizable padding color using high-performance C++ processing.</p>
227
251
 
228
252
  <h3>Details</h3>
229
- <p>This node rotates images clockwise by a specified angle in degrees. When rotation creates areas outside the original image bounds, these areas are filled with the specified padding color. The rotation operation supports both single images and arrays, with dynamic angle values from various sources.</p>
253
+ <p>This node rotates images counter-clockwise by a specified angle in degrees. When rotation creates areas outside the original image bounds, these areas are filled with the specified padding color. The rotation operation supports both single images and arrays, with dynamic angle values from various sources.</p>
230
254
 
231
255
  <h3>Properties</h3>
232
256
  <dl class="message-properties">
@@ -239,7 +263,7 @@
239
263
  <dt>Quality <span class="property-type">number</span></dt>
240
264
  <dd>Compression quality for JPEG and WebP formats (1-100). Only visible when jpg or webp format is selected. Default: 90.</dd>
241
265
  <dt>Angle <span class="property-type">number|string</span></dt>
242
- <dd>Rotation angle in degrees (clockwise). Can be a fixed number or dynamic value from msg property, flow, or global context. Supports decimal values.</dd>
266
+ <dd>Rotation angle in degrees (counter-clockwise). Can be a fixed number or dynamic value from msg property, flow, or global context. Supports decimal values.</dd>
243
267
  <dt>Pad Color <span class="property-type">string</span></dt>
244
268
  <dd>Color to fill areas created by rotation, specified as hexadecimal color (#RRGGBB). Default: #000000 (black).</dd>
245
269
  </dl>
@@ -258,7 +282,7 @@
258
282
 
259
283
  <h3>Rotation Behavior</h3>
260
284
  <ul>
261
- <li><strong>Direction:</strong> Clockwise rotation (positive angles)</li>
285
+ <li><strong>Direction:</strong> Counter-clockwise rotation (positive angles)</li>
262
286
  <li><strong>Angle Range:</strong> Any angle supported (0-360° and beyond)</li>
263
287
  <li><strong>Padding:</strong> Areas outside original bounds filled with specified color</li>
264
288
  <li><strong>Precision:</strong> Decimal angles supported (e.g., 45.5°, 30.25°)</li>
@@ -267,8 +291,8 @@
267
291
 
268
292
  <h3>Examples</h3>
269
293
  <ul>
270
- <li><strong>90° Rotation:</strong> Angle: 90 → Image rotated 90° clockwise</li>
271
- <li><strong>Custom Angle:</strong> Angle: 45.5 → Image rotated 45.5° clockwise</li>
294
+ <li><strong>90° Rotation:</strong> Angle: 90 → Image rotated 90° counter-clockwise</li>
295
+ <li><strong>Custom Angle:</strong> Angle: 45.5 → Image rotated 45.5° counter-clockwise</li>
272
296
  <li><strong>Dynamic Angle:</strong> Angle: msg.rotationAngle → Use angle from message property</li>
273
297
  <li><strong>White Padding:</strong> Pad Color: #FFFFFF → White background for rotated areas</li>
274
298
  <li><strong>Transparent Padding:</strong> For RGBA images, use appropriate color with alpha channel</li>
@@ -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 padColorHex = config.padColor || '#000000';
46
48
 
47
49
  // Validate input images with error passthrough
@@ -69,7 +71,7 @@ module.exports = function (RED) {
69
71
 
70
72
  /* ——— lanzar rotaciones en paralelo ——— */
71
73
  const promises = imgs.map(img =>
72
- CppProcessor.rotate(img, angle, padColorHex, outputFormat, outputQuality, pngOptimize)
74
+ CppProcessor.rotate(img, angle, padColorHex, cppFormat, outputQuality, pngOptimize)
73
75
  );
74
76
 
75
77
  const results = await Promise.all(promises);
@@ -84,6 +86,12 @@ module.exports = function (RED) {
84
86
  return acc;
85
87
  }, { totalConvertMs: 0, totalTaskMs: 0, encodeMs: 0, images: [] });
86
88
 
89
+ if (useSharpWebp) {
90
+ for (let i = 0; i < images.length; i++) {
91
+ images[i] = await NodeUtils.encodeWebpAdvanced(images[i], config);
92
+ }
93
+ }
94
+
87
95
  const out = Array.isArray(originalPayload) ? images : images[0];
88
96
  const durMs = performance.now() - t0;
89
97
 
@@ -42,6 +42,7 @@
42
42
  "padding": "nodes/transform/padding.js",
43
43
  "filter": "nodes/transform/filter.js",
44
44
  "draw": "nodes/transform/draw.js",
45
+ "color-convert": "nodes/transform/color-convert.js",
45
46
  "mosaic": "nodes/mix/mosaic.js",
46
47
  "advanced-mosaic": "nodes/mix/advanced-mosaic.js",
47
48
  "blend": "nodes/blend/blend.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools",
3
- "version": "1.2.0",
3
+ "version": "1.2.3",
4
4
  "description": "Node-RED Image Processing Toolkit",
5
5
  "main": "install.sh",
6
6
  "directories": {
@@ -59,6 +59,7 @@
59
59
  "padding": "node-red-contrib-image-tools/nodes/transform/padding.js",
60
60
  "filter": "node-red-contrib-image-tools/nodes/transform/filter.js",
61
61
  "draw": "node-red-contrib-image-tools/nodes/transform/draw.js",
62
+ "color-convert": "node-red-contrib-image-tools/nodes/transform/color-convert.js",
62
63
  "mosaic": "node-red-contrib-image-tools/nodes/mix/mosaic.js",
63
64
  "advanced-mosaic": "node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js",
64
65
  "blend": "node-red-contrib-image-tools/nodes/blend/blend.js",
@@ -21,7 +21,8 @@
21
21
  "src/add-masks.cpp",
22
22
  "src/add-bbs.cpp",
23
23
  "src/image-align.cpp",
24
- "src/draw.cpp"
24
+ "src/draw.cpp",
25
+ "src/color-convert.cpp"
25
26
  ],
26
27
  "defines": [
27
28
  "NAPI_CPP_EXCEPTIONS"
@@ -152,14 +152,14 @@ public:
152
152
  }
153
153
  // Default based on channel count
154
154
  else {
155
- channel = (images_[i].channels() == 4) ? "BGRA"
156
- : (images_[i].channels() == 3) ? "BGR"
155
+ channel = (images_[i].channels() == 4) ? "RGBA"
156
+ : (images_[i].channels() == 3) ? "RGB"
157
157
  : "GRAY";
158
158
  }
159
159
  } else {
160
160
  // Buffer input - determine from OpenCV Mat
161
- channel = (images_[i].channels() == 4) ? "BGRA"
162
- : (images_[i].channels() == 3) ? "BGR"
161
+ channel = (images_[i].channels() == 4) ? "RGBA"
162
+ : (images_[i].channels() == 3) ? "RGB"
163
163
  : "GRAY";
164
164
  }
165
165