@rosepetal/node-red-contrib-image-tools 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +6 -0
- package/.github/workflows/build-prebuild.yml +326 -0
- package/LICENSE +13 -0
- package/README.md +161 -0
- package/artifacts/darwin-arm64/package.json +25 -0
- package/artifacts/linux-arm64/package.json +26 -0
- package/artifacts/linux-x64/package.json +26 -0
- package/artifacts/linuxmusl-x64/package.json +26 -0
- package/assets/flow_time_example.gif +0 -0
- package/assets/nodes/io/array-in-demo.gif +0 -0
- package/assets/nodes/io/array-out-demo.gif +0 -0
- package/assets/nodes/io/array-select-demo.gif +0 -0
- package/assets/nodes/io/image-in-demo.gif +0 -0
- package/assets/nodes/mix/concat-demo.gif +0 -0
- package/assets/nodes/mix/mosaic-demo.gif +0 -0
- package/assets/nodes/transform/crop-demo.gif +0 -0
- package/assets/nodes/transform/filter-demo.gif +0 -0
- package/assets/nodes/transform/padding-demo.gif +0 -0
- package/assets/nodes/transform/resize-demo.gif +0 -0
- package/assets/nodes/transform/rotate-demo.gif +0 -0
- package/docs/nodes/blend/add-mask.md +275 -0
- package/docs/nodes/blend/add-masks.md +284 -0
- package/docs/nodes/blend/blend.md +248 -0
- package/docs/nodes/io/array-in.md +119 -0
- package/docs/nodes/io/array-out.md +150 -0
- package/docs/nodes/io/array-select.md +157 -0
- package/docs/nodes/io/image-in.md +131 -0
- package/docs/nodes/io/image-out.md +179 -0
- package/docs/nodes/io/queue.md +57 -0
- package/docs/nodes/io/save-file.md +30 -0
- package/docs/nodes/mix/advanced-mosaic.md +108 -0
- package/docs/nodes/mix/concat.md +127 -0
- package/docs/nodes/mix/mosaic.md +146 -0
- package/docs/nodes/specialized/cropBB.md +271 -0
- package/docs/nodes/specialized/image-align.md +426 -0
- package/docs/nodes/transform/crop.md +132 -0
- package/docs/nodes/transform/draw.md +77 -0
- package/docs/nodes/transform/filter.md +84 -0
- package/docs/nodes/transform/padding.md +133 -0
- package/docs/nodes/transform/resize.md +158 -0
- package/docs/nodes/transform/rotate.md +121 -0
- package/docs/nodes/util/block-detect.md +46 -0
- package/install.sh +144 -0
- package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
- package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
- package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
- package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
- package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
- package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
- package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
- package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
- package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
- package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
- package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
- package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
- package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
- package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
- package/node-red-contrib-image-tools/package.json +64 -0
- package/npm/darwin-arm64/lib/.gitkeep +1 -0
- package/npm/darwin-arm64/package.json +25 -0
- package/npm/darwin-x64/lib/.gitkeep +1 -0
- package/npm/darwin-x64/package.json +25 -0
- package/npm/linux-arm64/lib/.gitkeep +1 -0
- package/npm/linux-arm64/package.json +26 -0
- package/npm/linux-x64/lib/.gitkeep +1 -0
- package/npm/linux-x64/package.json +26 -0
- package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
- package/npm/linuxmusl-x64/package.json +26 -0
- package/npm/win32-x64/lib/.gitkeep +1 -0
- package/npm/win32-x64/package.json +25 -0
- package/package.json +74 -0
- package/rosepetal-image-engine/binding.gyp +153 -0
- package/rosepetal-image-engine/package.json +19 -0
- package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
- package/rosepetal-image-engine/src/add-mask.cpp +240 -0
- package/rosepetal-image-engine/src/add-masks.cpp +638 -0
- package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
- package/rosepetal-image-engine/src/blend.cpp +200 -0
- package/rosepetal-image-engine/src/concat.cpp +329 -0
- package/rosepetal-image-engine/src/crop.cpp +139 -0
- package/rosepetal-image-engine/src/draw.cpp +414 -0
- package/rosepetal-image-engine/src/filter.cpp +230 -0
- package/rosepetal-image-engine/src/filters/kernels.h +171 -0
- package/rosepetal-image-engine/src/image-align.cpp +551 -0
- package/rosepetal-image-engine/src/main.cpp +36 -0
- package/rosepetal-image-engine/src/mosaic.cpp +373 -0
- package/rosepetal-image-engine/src/padding.cpp +124 -0
- package/rosepetal-image-engine/src/resize.cpp +210 -0
- package/rosepetal-image-engine/src/rotate.cpp +177 -0
- package/rosepetal-image-engine/src/utils.h +563 -0
- package/rosepetal-image-engine/test-formats.js +119 -0
- package/scripts/build-opencv-static.ps1 +166 -0
- package/scripts/build-opencv-static.sh +147 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('image-in', {
|
|
3
|
+
category: 'RP Image',
|
|
4
|
+
color: '#A6C8A6',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
filePath: { value: "", required: true },
|
|
8
|
+
filePathType: { value: "str" },
|
|
9
|
+
// Nuevas propiedades para el destino de salida
|
|
10
|
+
outputPath: { value: "payload" },
|
|
11
|
+
outputPathType: { value: "msg" },
|
|
12
|
+
// Debug configuration
|
|
13
|
+
debugEnabled: { value: false },
|
|
14
|
+
debugWidth: { value: 200 },
|
|
15
|
+
debugWidthType: { value: "num" }
|
|
16
|
+
},
|
|
17
|
+
inputs: 1,
|
|
18
|
+
outputs: 1,
|
|
19
|
+
icon: "font-awesome/fa-file-image-o",
|
|
20
|
+
label: function() {
|
|
21
|
+
return this.name || this.filePath.split('/').pop() || "image in";
|
|
22
|
+
},
|
|
23
|
+
oneditprepare: function() {
|
|
24
|
+
// Inicializamos el widget TypedInput para el archivo de entrada
|
|
25
|
+
$("#node-input-filePath").typedInput({
|
|
26
|
+
default: 'str',
|
|
27
|
+
types: ['str', 'msg', 'flow', 'global'],
|
|
28
|
+
typeField: "#node-input-filePathType"
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Inicializamos el widget TypedInput para el campo de salida
|
|
32
|
+
$("#node-input-outputPath").typedInput({
|
|
33
|
+
default: 'msg', // Por defecto, la salida va al 'msg'
|
|
34
|
+
types: ['msg', 'flow', 'global'], // Opciones disponibles
|
|
35
|
+
typeField: "#node-input-outputPathType" // Campo oculto para guardar el tipo
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// === Debug Display Logic ===
|
|
39
|
+
const debugCheckbox = $('#node-input-debugEnabled');
|
|
40
|
+
const debugWidthRow = $('#debug-width-row');
|
|
41
|
+
|
|
42
|
+
// Initialize debug width TypedInput
|
|
43
|
+
$("#node-input-debugWidth").typedInput({
|
|
44
|
+
default: 'num',
|
|
45
|
+
types: ['num', 'msg', 'flow', 'global'],
|
|
46
|
+
typeField: "#node-input-debugWidthType"
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Show/hide debug width based on checkbox
|
|
50
|
+
function updateDebugWidthVisibility() {
|
|
51
|
+
if (debugCheckbox.prop('checked')) {
|
|
52
|
+
debugWidthRow.show();
|
|
53
|
+
} else {
|
|
54
|
+
debugWidthRow.hide();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
debugCheckbox.change(function() {
|
|
59
|
+
const enabled = $(this).prop('checked');
|
|
60
|
+
updateDebugWidthVisibility();
|
|
61
|
+
// Store debug state for runtime access
|
|
62
|
+
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Initialize visibility
|
|
66
|
+
updateDebugWidthVisibility();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<script type="text/x-red" data-template-name="image-in">
|
|
72
|
+
<div class="form-row">
|
|
73
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
74
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
75
|
+
</div>
|
|
76
|
+
<div class="form-row">
|
|
77
|
+
<label for="node-input-filePath"><i class="fa fa-folder-open"></i> File Path</label>
|
|
78
|
+
<input type="text" id="node-input-filePath" style="width: 70%;" placeholder="/path/to/your/image.jpg">
|
|
79
|
+
<input type="hidden" id="node-input-filePathType">
|
|
80
|
+
</div>
|
|
81
|
+
<hr>
|
|
82
|
+
<div class="form-row">
|
|
83
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
84
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
85
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<!-- Debug Configuration -->
|
|
89
|
+
<div class="form-row">
|
|
90
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
91
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
92
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show loaded image</label>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
95
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
96
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
97
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
98
|
+
</div>
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<script type="text/x-red" data-help-name="image-in">
|
|
102
|
+
<p>Loads an image file from the filesystem and outputs it as a raw image object for processing in the Node-RED flow.</p>
|
|
103
|
+
|
|
104
|
+
<h3>Details</h3>
|
|
105
|
+
<p>This node reads image files from disk and converts them into the standard image format used throughout the Rosepetal Image Tools. It supports various image formats including JPEG, PNG, WebP, and BMP. The image is decoded using a high-performance C++ backend with OpenCV.</p>
|
|
106
|
+
|
|
107
|
+
<h3>Properties</h3>
|
|
108
|
+
<dl class="message-properties">
|
|
109
|
+
<dt>File Path <span class="property-type">string | msg | flow | global</span></dt>
|
|
110
|
+
<dd>The path to the image file on the server filesystem. Can be a static string (absolute or relative path) or dynamically resolved from message properties, flow context, or global context. Supports common image formats: JPEG, PNG, WebP, BMP.</dd>
|
|
111
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
112
|
+
<dd>The location where the resulting image object will be stored. You can select between <code>msg</code>, <code>flow</code>, or <code>global</code> context. Defaults to <code>msg.payload</code>.</dd>
|
|
113
|
+
</dl>
|
|
114
|
+
|
|
115
|
+
<h3>Inputs</h3>
|
|
116
|
+
<dl class="message-properties">
|
|
117
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
118
|
+
<dd>Input message (content is ignored, only triggers the node operation).</dd>
|
|
119
|
+
</dl>
|
|
120
|
+
|
|
121
|
+
<h3>Outputs</h3>
|
|
122
|
+
<p>The node sets the property specified in 'Output to' with the processed image object using the standard format:</p>
|
|
123
|
+
<pre>{
|
|
124
|
+
data: Buffer, // Raw pixel data
|
|
125
|
+
width: number, // Image width in pixels
|
|
126
|
+
height: number, // Image height in pixels
|
|
127
|
+
channels: number, // Channel count (1, 3, 4)
|
|
128
|
+
colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
|
|
129
|
+
dtype: string // "uint8", "uint16", "float32"
|
|
130
|
+
}</pre>
|
|
131
|
+
|
|
132
|
+
<h3>Examples</h3>
|
|
133
|
+
<ul>
|
|
134
|
+
<li><strong>Static Path:</strong> Set File Path to <code>/path/to/image.jpg</code> (string type) and Output to <code>msg.payload</code></li>
|
|
135
|
+
<li><strong>Dynamic Path from Message:</strong> Set File Path from <code>msg.imagePath</code> to load different images based on message content</li>
|
|
136
|
+
<li><strong>Flow Context Path:</strong> Set File Path from <code>flow.currentImageFile</code> to use a path stored in flow context</li>
|
|
137
|
+
<li><strong>Multiple Images:</strong> Connect to an array-out node to work with image collections</li>
|
|
138
|
+
<li><strong>Processing Pipeline:</strong> Connect to transform nodes like resize, rotate, or crop for image manipulation</li>
|
|
139
|
+
</ul>
|
|
140
|
+
|
|
141
|
+
<h3>Error Handling</h3>
|
|
142
|
+
<p>If the file path is invalid or the image cannot be read, the node will display a warning and not propagate the message. Check the debug panel for specific error details.</p>
|
|
143
|
+
|
|
144
|
+
<h3>Performance</h3>
|
|
145
|
+
<p>Image loading is performed asynchronously using the C++ backend for optimal performance. The node status displays processing time information.</p>
|
|
146
|
+
</script>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Node.js logic for the Image-In node with dynamic output path.
|
|
3
|
+
* Uses Sharp for complete image decoding and metadata extraction.
|
|
4
|
+
* @author Rosepetal
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const sharp = require('sharp');
|
|
8
|
+
const fs = require('fs').promises;
|
|
9
|
+
|
|
10
|
+
module.exports = function(RED) {
|
|
11
|
+
const NodeUtils = require('../../lib/node-utils.js')(RED);
|
|
12
|
+
|
|
13
|
+
function ImageInNode(config) {
|
|
14
|
+
RED.nodes.createNode(this, config);
|
|
15
|
+
const node = this;
|
|
16
|
+
|
|
17
|
+
node.on('input', async function(msg, send, done) {
|
|
18
|
+
try {
|
|
19
|
+
let filePath;
|
|
20
|
+
if (config.filePathType === 'msg' || config.filePathType === 'flow' || config.filePathType === 'global') {
|
|
21
|
+
filePath = RED.util.evaluateNodeProperty(config.filePath, config.filePathType, node, msg);
|
|
22
|
+
} else {
|
|
23
|
+
filePath = config.filePath; // str type
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!filePath) {
|
|
27
|
+
node.warn("File path is not configured or resolved.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
node.status({ fill: "blue", shape: "dot", text: "reading..." });
|
|
32
|
+
|
|
33
|
+
// Check file accessibility
|
|
34
|
+
try {
|
|
35
|
+
await fs.access(filePath, fs.constants.R_OK);
|
|
36
|
+
} catch (accessErr) {
|
|
37
|
+
node.warn(`Cannot access file: ${filePath}`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Use Sharp to decode image with full metadata
|
|
42
|
+
const { data, info } = await sharp(filePath)
|
|
43
|
+
.raw()
|
|
44
|
+
.toBuffer({ resolveWithObject: true });
|
|
45
|
+
|
|
46
|
+
// Determine colorSpace from Sharp info
|
|
47
|
+
let colorSpace;
|
|
48
|
+
switch (info.channels) {
|
|
49
|
+
case 1: colorSpace = 'GRAY'; break;
|
|
50
|
+
case 3: colorSpace = 'RGB'; break;
|
|
51
|
+
case 4: colorSpace = 'RGBA'; break;
|
|
52
|
+
default: throw new Error(`Unsupported number of channels: ${info.channels}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Create complete image structure with all metadata
|
|
56
|
+
const outputImageObject = {
|
|
57
|
+
data: data,
|
|
58
|
+
width: info.width,
|
|
59
|
+
height: info.height,
|
|
60
|
+
channels: info.channels,
|
|
61
|
+
colorSpace: colorSpace,
|
|
62
|
+
dtype: "uint8"
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Debug image display if enabled
|
|
66
|
+
if (config.debugEnabled) {
|
|
67
|
+
try {
|
|
68
|
+
// Resolve debug width
|
|
69
|
+
let debugWidth = NodeUtils.resolveDimension(
|
|
70
|
+
node,
|
|
71
|
+
config.debugWidthType || "num",
|
|
72
|
+
config.debugWidth || 200,
|
|
73
|
+
msg
|
|
74
|
+
);
|
|
75
|
+
debugWidth = Math.max(1, parseInt(debugWidth) || 200);
|
|
76
|
+
|
|
77
|
+
// Since we already have the image loaded, reuse it for debug display
|
|
78
|
+
// Convert to JPEG buffer for debug display using the Sharp instance
|
|
79
|
+
const debugBuffer = await sharp(data, {
|
|
80
|
+
raw: { width: info.width, height: info.height, channels: info.channels }
|
|
81
|
+
})
|
|
82
|
+
.resize(debugWidth, null, {
|
|
83
|
+
withoutEnlargement: false,
|
|
84
|
+
fit: 'inside'
|
|
85
|
+
})
|
|
86
|
+
.jpeg({ quality: 90 })
|
|
87
|
+
.toBuffer();
|
|
88
|
+
|
|
89
|
+
// Create debug result manually since we're using Sharp directly
|
|
90
|
+
const base64 = debugBuffer.toString('base64');
|
|
91
|
+
const debugMetadata = await sharp(debugBuffer).metadata();
|
|
92
|
+
|
|
93
|
+
// Send image to frontend via WebSocket for inline display
|
|
94
|
+
try {
|
|
95
|
+
RED.comms.publish("debug-image", {
|
|
96
|
+
id: node.id,
|
|
97
|
+
data: base64,
|
|
98
|
+
format: 'jpg debug',
|
|
99
|
+
mimeType: 'jpeg',
|
|
100
|
+
size: debugBuffer.length,
|
|
101
|
+
debugWidth: debugMetadata.width || debugWidth,
|
|
102
|
+
debugHeight: debugMetadata.height || debugWidth
|
|
103
|
+
});
|
|
104
|
+
} catch (wsError) {
|
|
105
|
+
node.warn(`Debug WebSocket error: ${wsError.message}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
} catch (debugError) {
|
|
109
|
+
node.warn(`Debug display error: ${debugError.message}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const outputPath = config.outputPath || "payload";
|
|
114
|
+
const outputPathType = config.outputPathType || "msg";
|
|
115
|
+
|
|
116
|
+
if (outputPathType === 'msg') {
|
|
117
|
+
RED.util.setMessageProperty(msg, outputPath, outputImageObject);
|
|
118
|
+
} else if (outputPathType === 'flow') {
|
|
119
|
+
node.context().flow.set(outputPath, outputImageObject);
|
|
120
|
+
} else if (outputPathType === 'global') {
|
|
121
|
+
node.context().global.set(outputPath, outputImageObject);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Update status with debug info if enabled
|
|
125
|
+
let statusText = `${info.width}x${info.height} to ${outputPathType}.${outputPath}`;
|
|
126
|
+
if (config.debugEnabled) {
|
|
127
|
+
statusText += ' | jpg debug';
|
|
128
|
+
}
|
|
129
|
+
node.status({ fill: "green", shape: "dot", text: statusText });
|
|
130
|
+
|
|
131
|
+
send(msg);
|
|
132
|
+
if (done) { done(); }
|
|
133
|
+
|
|
134
|
+
} catch (err) {
|
|
135
|
+
node.status({ fill: "red", shape: "ring", text: "Error" });
|
|
136
|
+
node.warn(`Error reading image file: ${err.message}`);
|
|
137
|
+
// Don't send message on error
|
|
138
|
+
if (done) { done(); }
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
RED.nodes.registerType("image-in", ImageInNode);
|
|
143
|
+
};
|