Skip to content

Commit 28a8bbe

Browse files
author
Jacek Bilski
committed
Using exiftool to extract exif data from images. Downside: we're reading the file twice, once by sharp, once by exiftool.
1 parent c2e960e commit 28a8bbe

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let sharp = require("sharp");
44
let SVGO = require("svgo");
55
let { stat, readFile } = require("fs").promises;
66
let { abort } = require("faucet-pipeline-core/lib/util");
7+
const exiftool = require("exiftool-vendored").exiftool;
78

89
// we can optimize the settings here, but some would require libvips
910
// to be compiled with additional stuff
@@ -91,6 +92,14 @@ async function processFile(fileName,
9192
if(fingerprint !== undefined) {
9293
writeOptions.fingerprint = fingerprint;
9394
}
95+
96+
let tags = await exiftool.read(sourcePath);
97+
let meta = {};
98+
if(tags) {
99+
meta.exif = tags;
100+
}
101+
102+
writeOptions.meta = meta;
94103
return assetManager.writeFile(targetPath, output, writeOptions);
95104
}
96105

@@ -134,7 +143,6 @@ async function optimizeBitmap(sourcePath, format,
134143
default:
135144
abort(`unsupported format ${format}. We support: JPG, PNG, WebP, SVG`);
136145
}
137-
138146
return image.toBuffer();
139147
}
140148

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
},
2121
"homepage": "https://www.faucet-pipeline.org",
2222
"dependencies": {
23-
"faucet-pipeline-core": "^1.4.0",
23+
"exiftool-vendored": "^11.3.0",
24+
"faucet-pipeline-core": "github:faucet-pipeline/faucet-pipeline-core#topic/marx",
2425
"sharp": "^0.25.2",
2526
"svgo": "^1.3.2"
2627
},

0 commit comments

Comments
 (0)