@rosepetal/node-red-contrib-image-tools 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build-prebuild.yml +3 -0
- package/install.sh +8 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +64 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +242 -3
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +10 -3
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +282 -4
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +15 -8
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +206 -3
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +10 -3
- package/node-red-contrib-image-tools/nodes/blend/blend.html +332 -4
- package/node-red-contrib-image-tools/nodes/blend/blend.js +10 -3
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +147 -3
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/image-in.html +81 -2
- package/node-red-contrib-image-tools/nodes/io/image-in.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/image-out.html +197 -3
- package/node-red-contrib-image-tools/nodes/io/image-out.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +398 -3
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +11 -4
- package/node-red-contrib-image-tools/nodes/mix/concat.html +245 -5
- package/node-red-contrib-image-tools/nodes/mix/concat.js +10 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +307 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +10 -3
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +217 -4
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +11 -2
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +285 -4
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +9 -2
- package/node-red-contrib-image-tools/nodes/transform/color-convert.html +169 -6
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/crop.html +237 -5
- package/node-red-contrib-image-tools/nodes/transform/crop.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/draw.html +152 -3
- package/node-red-contrib-image-tools/nodes/transform/draw.js +10 -3
- package/node-red-contrib-image-tools/nodes/transform/filter.html +369 -4
- package/node-red-contrib-image-tools/nodes/transform/filter.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/padding.html +316 -5
- package/node-red-contrib-image-tools/nodes/transform/padding.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/resize.html +203 -5
- package/node-red-contrib-image-tools/nodes/transform/resize.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +164 -5
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +11 -2
- package/package.json +71 -71
- package/scripts/dual-register.js +267 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- 1 ▸ Runtime registration -->
|
|
4
4
|
<script type="text/javascript">
|
|
5
|
-
|
|
5
|
+
var _rpNodeCfg = {
|
|
6
6
|
|
|
7
7
|
category:'RP Image',
|
|
8
8
|
color :'#DDA0DD',
|
|
@@ -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},
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
},
|
|
30
33
|
|
|
31
34
|
inputs:1, outputs:1,
|
|
32
|
-
label:function(){ return this.name || "mosaic"; },
|
|
35
|
+
label:function(){ return this.name || "rp-mosaic"; },
|
|
33
36
|
|
|
34
37
|
/* ---------------- oneditprepare ---------------- */
|
|
35
38
|
oneditprepare:function(){
|
|
@@ -136,6 +139,11 @@
|
|
|
136
139
|
const format = $("#node-input-outputFormat").val();
|
|
137
140
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
138
141
|
$("#png-optimize-row").toggle(format === "png");
|
|
142
|
+
// Show WebP advanced options only when WebP is selected
|
|
143
|
+
const isWebp = format === 'webp';
|
|
144
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
145
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
146
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
139
147
|
}
|
|
140
148
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
141
149
|
updateQualityVisibility(); // initial state
|
|
@@ -171,7 +179,9 @@
|
|
|
171
179
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
172
180
|
});
|
|
173
181
|
}
|
|
174
|
-
}
|
|
182
|
+
};
|
|
183
|
+
RED.nodes.registerType('rp-mosaic', _rpNodeCfg);
|
|
184
|
+
RED.nodes.registerType('mosaic', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
175
185
|
|
|
176
186
|
// Debug image display renderer - shared across all image processing nodes
|
|
177
187
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -284,6 +294,125 @@
|
|
|
284
294
|
</script>
|
|
285
295
|
|
|
286
296
|
<!-- 2 ▸ Edit‑dialog template -->
|
|
297
|
+
<script type="text/x-red" data-template-name="rp-mosaic">
|
|
298
|
+
|
|
299
|
+
<!-- Name -->
|
|
300
|
+
<div class="form-row">
|
|
301
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
302
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<hr>
|
|
306
|
+
|
|
307
|
+
<!-- STANDARD I/O SECTION (copied from crop.html) -->
|
|
308
|
+
<div class="form-row">
|
|
309
|
+
<label for="node-input-inputPath"><i class="fa fa-sign-in"></i> Input from</label>
|
|
310
|
+
<input type="text" id="node-input-inputPath" style="width: 70%;">
|
|
311
|
+
<input type="hidden" id="node-input-inputPathType">
|
|
312
|
+
</div>
|
|
313
|
+
<div class="form-row">
|
|
314
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
315
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
316
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
317
|
+
</div>
|
|
318
|
+
<div class="form-row">
|
|
319
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
320
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
321
|
+
<option value="raw">Raw (fastest)</option>
|
|
322
|
+
<option value="jpg">JPEG</option>
|
|
323
|
+
<option value="png">PNG</option>
|
|
324
|
+
<option value="webp">WebP</option>
|
|
325
|
+
</select>
|
|
326
|
+
</div>
|
|
327
|
+
<div class="form-row" id="quality-row">
|
|
328
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
329
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
330
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
331
|
+
</div>
|
|
332
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
333
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
334
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
335
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
336
|
+
</div>
|
|
337
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
338
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
339
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
340
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
341
|
+
</div>
|
|
342
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
343
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
344
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
345
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
346
|
+
</div>
|
|
347
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
348
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
349
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
350
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
353
|
+
<!-- Debug Configuration -->
|
|
354
|
+
<div class="form-row">
|
|
355
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
356
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
357
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
358
|
+
</div>
|
|
359
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
360
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
361
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
362
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
363
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
364
|
+
</div>
|
|
365
|
+
|
|
366
|
+
<hr>
|
|
367
|
+
|
|
368
|
+
<!-- CANVAS CONFIGURATION -->
|
|
369
|
+
<div class="form-row">
|
|
370
|
+
<label for="node-input-canvasWidth"><i class="fa fa-arrows-h"></i> Canvas Width</label>
|
|
371
|
+
<input type="text" id="node-input-canvasWidth" style="width: 70%;" placeholder="800">
|
|
372
|
+
<input type="hidden" id="node-input-canvasWidthType">
|
|
373
|
+
</div>
|
|
374
|
+
<div class="form-row">
|
|
375
|
+
<label for="node-input-canvasHeight"><i class="fa fa-arrows-v"></i> Canvas Height</label>
|
|
376
|
+
<input type="text" id="node-input-canvasHeight" style="width: 70%;" placeholder="600">
|
|
377
|
+
<input type="hidden" id="node-input-canvasHeightType">
|
|
378
|
+
</div>
|
|
379
|
+
<div class="form-row">
|
|
380
|
+
<label for="node-input-backgroundColor"><i class="fa fa-paint-brush"></i> Background Color</label>
|
|
381
|
+
<input type="color" id="node-input-backgroundColor" style="width: 70px; height: 30px;">
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
<div class="form-row">
|
|
385
|
+
<label for="node-input-coordNorm"><i class="fa fa-percent"></i> Normalized Coords</label>
|
|
386
|
+
<input type="checkbox" id="node-input-coordNorm" style="width: 20px; height: 20px;">
|
|
387
|
+
</div>
|
|
388
|
+
|
|
389
|
+
<!-- Tips that toggle -->
|
|
390
|
+
<div id="norm-enabled" class="form-tips" style="font-size: 0.85em; margin: 4px 0; color: #666;">
|
|
391
|
+
<b>Normalized ON:</b> position values must be between <code>0.0</code> and <code>1.0</code> (fractions of canvas dimensions).
|
|
392
|
+
</div>
|
|
393
|
+
<div id="norm-disabled" class="form-tips" style="font-size: 0.85em; margin: 4px 0; color: #666;">
|
|
394
|
+
<b>Normalized OFF:</b> position values are absolute pixels from top-left corner.
|
|
395
|
+
</div>
|
|
396
|
+
|
|
397
|
+
<hr>
|
|
398
|
+
|
|
399
|
+
<!-- POSITION MAPPING TABLE -->
|
|
400
|
+
<div class="form-row">
|
|
401
|
+
<label style="width: 100%; margin-bottom: 10px;"><i class="fa fa-th"></i> Image Positions</label>
|
|
402
|
+
<div id="position-container" style="width: 100%;"></div>
|
|
403
|
+
</div>
|
|
404
|
+
|
|
405
|
+
<div class="form-tips">
|
|
406
|
+
<b>Instructions:</b>
|
|
407
|
+
<ul>
|
|
408
|
+
<li><b>Array Index:</b> Which image from the input array to place (0 = first image, 1 = second, etc.)</li>
|
|
409
|
+
<li><b>X, Y Position:</b> Top-left corner coordinates on the canvas</li>
|
|
410
|
+
<li><b>Multiple Positions:</b> Same image can be placed multiple times at different positions</li>
|
|
411
|
+
<li><b>Dynamic Configuration:</b> Use Add/Remove buttons to manage position mappings</li>
|
|
412
|
+
</ul>
|
|
413
|
+
</div>
|
|
414
|
+
</script>
|
|
415
|
+
|
|
287
416
|
<script type="text/x-red" data-template-name="mosaic">
|
|
288
417
|
|
|
289
418
|
<!-- Name -->
|
|
@@ -324,6 +453,21 @@
|
|
|
324
453
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
325
454
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
326
455
|
</div>
|
|
456
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
457
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
458
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
459
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
460
|
+
</div>
|
|
461
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
462
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
463
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
464
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
465
|
+
</div>
|
|
466
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
467
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
468
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
469
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
470
|
+
</div>
|
|
327
471
|
|
|
328
472
|
<!-- Debug Configuration -->
|
|
329
473
|
<div class="form-row">
|
|
@@ -389,6 +533,166 @@
|
|
|
389
533
|
</script>
|
|
390
534
|
|
|
391
535
|
<!-- 3 ▸ Help panel -->
|
|
536
|
+
<script type="text/x-red" data-help-name="rp-mosaic">
|
|
537
|
+
<p><b>rosepetal-mosaic</b> creates a composite image by placing multiple images from an input array onto a canvas at specified positions. This node enables precise control over image positioning, supports normalized coordinates, and offers flexible canvas configuration for creating complex image layouts.</p>
|
|
538
|
+
|
|
539
|
+
<h3>Details</h3>
|
|
540
|
+
<p>This node processes arrays of images and places them onto a customizable canvas using high-performance C++ operations. It supports both absolute pixel coordinates and normalized coordinates (0.0-1.0), dynamic canvas sizing, and flexible positioning controls. The node handles both raw pixel data and encoded image files transparently, making it ideal for creating collages, dashboards, and composite layouts.</p>
|
|
541
|
+
|
|
542
|
+
<h3>Properties</h3>
|
|
543
|
+
<dl class="message-properties">
|
|
544
|
+
<dt>Input from <span class="property-type">string</span></dt>
|
|
545
|
+
<dd>Message property path containing the input image array. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
546
|
+
|
|
547
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
548
|
+
<dd>Message property path where the mosaic image will be stored. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
549
|
+
|
|
550
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
551
|
+
<dd>Format for the output image: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
552
|
+
|
|
553
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
554
|
+
<dd>Compression quality (1-100) for JPEG and WebP formats. Only visible when JPG or WebP is selected.</dd>
|
|
555
|
+
|
|
556
|
+
<dt>Canvas Width <span class="property-type">number|string</span></dt>
|
|
557
|
+
<dd>Width of the output canvas in pixels. Supports dynamic values from <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
558
|
+
|
|
559
|
+
<dt>Canvas Height <span class="property-type">number|string</span></dt>
|
|
560
|
+
<dd>Height of the output canvas in pixels. Supports dynamic values from <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
561
|
+
|
|
562
|
+
<dt>Background Color <span class="property-type">color</span></dt>
|
|
563
|
+
<dd>Canvas background color in hex format (e.g., #000000). Images are placed on top of this background.</dd>
|
|
564
|
+
|
|
565
|
+
<dt>Normalized Coords <span class="property-type">boolean</span></dt>
|
|
566
|
+
<dd>When enabled, position coordinates use normalized values (0.0-1.0) as fractions of canvas dimensions. When disabled, coordinates are absolute pixels.</dd>
|
|
567
|
+
|
|
568
|
+
<dt>Image Positions <span class="property-type">array</span></dt>
|
|
569
|
+
<dd>Dynamic table of position mappings. Each row specifies: Array Index (which input image), X Position, Y Position. Same image can be placed multiple times.</dd>
|
|
570
|
+
</dl>
|
|
571
|
+
|
|
572
|
+
<h3>Inputs</h3>
|
|
573
|
+
<p>The input should be an array of image objects in the standard format:</p>
|
|
574
|
+
<pre>{
|
|
575
|
+
data: Buffer, // Raw pixel data or encoded file buffer
|
|
576
|
+
width: number, // Image width in pixels
|
|
577
|
+
height: number, // Image height in pixels
|
|
578
|
+
channels: number, // Channel count (1=grayscale, 3=RGB, 4=RGBA)
|
|
579
|
+
colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
|
|
580
|
+
dtype: string // "uint8", "uint16", "float32"
|
|
581
|
+
}</pre>
|
|
582
|
+
<p>File buffers (JPEG, PNG, WebP, BMP) are automatically detected and decoded.</p>
|
|
583
|
+
|
|
584
|
+
<h3>Outputs</h3>
|
|
585
|
+
<p>Produces a single composite mosaic image in the specified format:</p>
|
|
586
|
+
<ul>
|
|
587
|
+
<li><b>Raw format:</b> Complete image object with pixel data and metadata</li>
|
|
588
|
+
<li><b>Encoded formats (JPG/PNG/WebP):</b> File buffer ready for storage or transmission</li>
|
|
589
|
+
</ul>
|
|
590
|
+
<p>Output dimensions match the configured canvas size. Images are placed at their specified positions, potentially overlapping if coordinates overlap.</p>
|
|
591
|
+
|
|
592
|
+
<h3>Position Mapping System</h3>
|
|
593
|
+
<h4>Array Index</h4>
|
|
594
|
+
<ul>
|
|
595
|
+
<li><b>Zero-based indexing:</b> 0 = first image, 1 = second image, etc.</li>
|
|
596
|
+
<li><b>Multiple placement:</b> Same image can be referenced multiple times for duplication</li>
|
|
597
|
+
<li><b>Out-of-bounds handling:</b> Invalid indices are gracefully ignored with warnings</li>
|
|
598
|
+
</ul>
|
|
599
|
+
|
|
600
|
+
<h4>Coordinate Systems</h4>
|
|
601
|
+
<ul>
|
|
602
|
+
<li><b>Absolute pixels (Normalized OFF):</b> Direct pixel coordinates from top-left corner (0,0)</li>
|
|
603
|
+
<li><b>Normalized coordinates (Normalized ON):</b> Values 0.0-1.0 as fractions of canvas dimensions</li>
|
|
604
|
+
<li><b>Position reference:</b> All coordinates specify the top-left corner of placed images</li>
|
|
605
|
+
</ul>
|
|
606
|
+
|
|
607
|
+
<h4>Dynamic Configuration</h4>
|
|
608
|
+
<ul>
|
|
609
|
+
<li><b>Add/Remove buttons:</b> Dynamically manage position mappings in the editor</li>
|
|
610
|
+
<li><b>Real-time validation:</b> Invalid values are automatically corrected</li>
|
|
611
|
+
<li><b>Persistent configuration:</b> Position mappings are saved with the flow</li>
|
|
612
|
+
</ul>
|
|
613
|
+
|
|
614
|
+
<h3>Examples</h3>
|
|
615
|
+
<h4>Photo Collage</h4>
|
|
616
|
+
<p>Create a photo collage with normalized positioning:</p>
|
|
617
|
+
<ul>
|
|
618
|
+
<li>Canvas: 1200x800 pixels</li>
|
|
619
|
+
<li>Normalized Coords: ON</li>
|
|
620
|
+
<li>Positions: (0, 0.1, 0.1), (1, 0.6, 0.1), (2, 0.1, 0.6), (3, 0.6, 0.6)</li>
|
|
621
|
+
<li>Background: White (#FFFFFF)</li>
|
|
622
|
+
</ul>
|
|
623
|
+
|
|
624
|
+
<h4>Dashboard Layout</h4>
|
|
625
|
+
<p>Create a dashboard with absolute positioning:</p>
|
|
626
|
+
<ul>
|
|
627
|
+
<li>Canvas: 1920x1080 pixels</li>
|
|
628
|
+
<li>Normalized Coords: OFF</li>
|
|
629
|
+
<li>Header image at (0, 0), sidebar at (0, 100), main content at (300, 100)</li>
|
|
630
|
+
<li>Background: Dark gray (#333333)</li>
|
|
631
|
+
</ul>
|
|
632
|
+
|
|
633
|
+
<h4>Dynamic Canvas from Context</h4>
|
|
634
|
+
<p>Use flow context for dynamic sizing:</p>
|
|
635
|
+
<ul>
|
|
636
|
+
<li>Canvas Width: flow.screenWidth</li>
|
|
637
|
+
<li>Canvas Height: flow.screenHeight</li>
|
|
638
|
+
<li>Input from: flow.thumbnails</li>
|
|
639
|
+
<li>Responsive positioning based on screen dimensions</li>
|
|
640
|
+
</ul>
|
|
641
|
+
|
|
642
|
+
<h3>Mosaic Patterns</h3>
|
|
643
|
+
<h4>Grid Layouts</h4>
|
|
644
|
+
<ul>
|
|
645
|
+
<li><b>Regular Grid:</b> Use normalized coordinates with calculated spacing (e.g., 0.25, 0.5, 0.75)</li>
|
|
646
|
+
<li><b>Asymmetric Grid:</b> Mix different image sizes with custom positioning</li>
|
|
647
|
+
<li><b>Overlapping Grid:</b> Create layered effects with overlapping positions</li>
|
|
648
|
+
</ul>
|
|
649
|
+
|
|
650
|
+
<h4>Artistic Arrangements</h4>
|
|
651
|
+
<ul>
|
|
652
|
+
<li><b>Scattered Layout:</b> Random positioning for organic arrangements</li>
|
|
653
|
+
<li><b>Circular Pattern:</b> Calculate positions around a center point</li>
|
|
654
|
+
<li><b>Layered Composition:</b> Z-order determined by position mapping sequence</li>
|
|
655
|
+
</ul>
|
|
656
|
+
|
|
657
|
+
<h3>Node Interactions</h3>
|
|
658
|
+
<ul>
|
|
659
|
+
<li><b>Upstream:</b> Works with <code>array-in</code>, <code>image-in</code>, or any nodes producing image arrays</li>
|
|
660
|
+
<li><b>Downstream:</b> Connect to <code>array-out</code>, file writers, or display nodes</li>
|
|
661
|
+
<li><b>Chaining:</b> Can be combined with <code>concat</code> and other processing nodes</li>
|
|
662
|
+
<li><b>Context Integration:</b> Supports dynamic canvas sizing and positioning via context</li>
|
|
663
|
+
<li><b>Flow Coordination:</b> Use with inject nodes for automated mosaic generation</li>
|
|
664
|
+
</ul>
|
|
665
|
+
|
|
666
|
+
<h3>Output Formats</h3>
|
|
667
|
+
<ul>
|
|
668
|
+
<li><b>Raw (fastest):</b> Uncompressed pixel data, ideal for further processing or chaining</li>
|
|
669
|
+
<li><b>JPEG:</b> Lossy compression with quality control, smaller files for web display</li>
|
|
670
|
+
<li><b>PNG:</b> Lossless compression, preserves transparency, larger files</li>
|
|
671
|
+
<li><b>WebP:</b> Modern format with superior compression and quality control</li>
|
|
672
|
+
</ul>
|
|
673
|
+
|
|
674
|
+
<h3>Error Handling</h3>
|
|
675
|
+
<ul>
|
|
676
|
+
<li><b>Input Validation:</b> Comprehensive validation of image array structure and position mappings</li>
|
|
677
|
+
<li><b>Bounds Checking:</b> Automatic handling of out-of-bounds coordinates and array indices</li>
|
|
678
|
+
<li><b>Canvas Validation:</b> Ensures valid canvas dimensions with minimum size constraints</li>
|
|
679
|
+
<li><b>Memory Management:</b> Efficient memory usage with automatic cleanup and garbage collection</li>
|
|
680
|
+
<li><b>Position Validation:</b> Validates coordinate ranges for both absolute and normalized modes</li>
|
|
681
|
+
<li><b>Warning System:</b> Uses <code>node.warn()</code> for non-fatal issues without stopping flow execution</li>
|
|
682
|
+
</ul>
|
|
683
|
+
|
|
684
|
+
<h3>Performance</h3>
|
|
685
|
+
<ul>
|
|
686
|
+
<li><b>C++ Backend:</b> High-performance OpenCV-based processing with optimized build flags</li>
|
|
687
|
+
<li><b>Zero-Copy Operations:</b> Minimal memory allocation and copying for maximum efficiency</li>
|
|
688
|
+
<li><b>Parallel Processing:</b> Image placement operations processed in parallel using Promise.all()</li>
|
|
689
|
+
<li><b>Canvas Optimization:</b> Efficient canvas initialization and background rendering</li>
|
|
690
|
+
<li><b>Memory Pooling:</b> Reuses memory buffers across operations to reduce allocation overhead</li>
|
|
691
|
+
<li><b>Build Optimization:</b> Compiled with <code>-O3</code>, <code>-march=native</code>, <code>-ffast-math</code> flags</li>
|
|
692
|
+
<li><b>Position Caching:</b> Optimized coordinate calculations for repeated positioning operations</li>
|
|
693
|
+
</ul>
|
|
694
|
+
</script>
|
|
695
|
+
|
|
392
696
|
<script type="text/x-red" data-help-name="mosaic">
|
|
393
697
|
<p><b>rosepetal-mosaic</b> creates a composite image by placing multiple images from an input array onto a canvas at specified positions. This node enables precise control over image positioning, supports normalized coordinates, and offers flexible canvas configuration for creating complex image layouts.</p>
|
|
394
698
|
|
|
@@ -50,6 +50,8 @@ module.exports = function (RED) {
|
|
|
50
50
|
const outputFormat = config.outputFormat || 'raw';
|
|
51
51
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
52
52
|
const pngOptimize = config.pngOptimize || false;
|
|
53
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
54
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
53
55
|
|
|
54
56
|
/* Canvas configuration */
|
|
55
57
|
const canvasWidth = Number(NodeUtils.resolveDimension(node, config.canvasWidthType, config.canvasWidth, msg));
|
|
@@ -93,18 +95,22 @@ module.exports = function (RED) {
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/* Single ultra-fast C++ call */
|
|
96
|
-
|
|
98
|
+
let { image, timing = {} } = await CppProcessor.mosaic(
|
|
97
99
|
imageArray,
|
|
98
100
|
canvasWidth,
|
|
99
101
|
canvasHeight,
|
|
100
102
|
backgroundColor,
|
|
101
103
|
validPositions,
|
|
102
104
|
normalized,
|
|
103
|
-
|
|
105
|
+
cppFormat,
|
|
104
106
|
outputQuality,
|
|
105
107
|
pngOptimize
|
|
106
108
|
);
|
|
107
109
|
|
|
110
|
+
if (useSharpWebp) {
|
|
111
|
+
image = await NodeUtils.encodeWebpAdvanced(image, config);
|
|
112
|
+
}
|
|
113
|
+
|
|
108
114
|
/* Set output */
|
|
109
115
|
NodeUtils.setOutputValue(node, msg, outputPath, outputPathType, image);
|
|
110
116
|
|
|
@@ -184,5 +190,6 @@ module.exports = function (RED) {
|
|
|
184
190
|
});
|
|
185
191
|
}
|
|
186
192
|
|
|
187
|
-
RED.nodes.registerType('mosaic', MosaicNode);
|
|
193
|
+
RED.nodes.registerType('rp-mosaic', MosaicNode);
|
|
194
|
+
RED.nodes.registerType('mosaic', MosaicNode); // legacy compat
|
|
188
195
|
};
|