bump to latest libs, fix reading correct property

This commit is contained in:
Dave Conway-Jones 2025-01-30 11:25:39 +00:00
parent 14f68063c5
commit 0b556bade8
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643
2 changed files with 7 additions and 3 deletions

View File

@ -81,14 +81,18 @@ module.exports = function(RED) {
else if (node.mode === "worldmap" && (msg.payload.action !== "file" || msg.payload.type.indexOf("image") === -1)) { return; } // in case worldmap-in not filtered. else if (node.mode === "worldmap" && (msg.payload.action !== "file" || msg.payload.type.indexOf("image") === -1)) { return; } // in case worldmap-in not filtered.
try { try {
var value = RED.util.getMessageProperty(msg,node.property); var value = RED.util.getMessageProperty(msg,node.property);
if (value !== undefined) { if (value !== undefined) {
if (typeof value === "string") { // it must be a base64 encoded inline image type if (typeof value === "string") { // it must be a base64 encoded inline image type
if (value.indexOf('data:image') !== -1) { if (value.indexOf('data:image') !== -1) {
value = new Buffer.from(value.replace(/^data:image\/[a-z]+;base64,/, ""), 'base64'); value = new Buffer.from(value.replace(/^data:image\/[a-z]+;base64,/, ""), 'base64');
} }
else {
value = new Buffer.from(value, 'base64');
}
} }
if (Buffer.isBuffer(value)) { // or a proper jpg buffer if (Buffer.isBuffer(value)) { // or a proper jpg buffer
msg.exif = ExifReader.load(msg.payload); msg.exif = ExifReader.load(value);
for (const p in msg.exif) { for (const p in msg.exif) {
if (msg.exif.hasOwnProperty(p)) { if (msg.exif.hasOwnProperty(p)) {
msg.exif[p] = msg.exif[p].description msg.exif[p] = msg.exif[p].description

View File

@ -1,9 +1,9 @@
{ {
"name": "node-red-node-exif", "name": "node-red-node-exif",
"version": "1.0.0", "version": "1.1.0",
"description": "A Node-RED node that extracts Exif information from JPEG image buffers.", "description": "A Node-RED node that extracts Exif information from JPEG image buffers.",
"dependencies": { "dependencies": {
"exifreader": "^4.20.0" "exifreader": "^4.26.1"
}, },
"bundledDependencies": [ "bundledDependencies": [
"exifreader" "exifreader"