Skip to content

Commit 2eca876

Browse files
Jacek Bilskimoonglum
authored andcommitted
Using exiftool to extract exif data from images.
Downside: we're reading the file twice, once by sharp, once by exiftool.
1 parent 96e734e commit 2eca876

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
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+
let { exiftool } = require("exiftool-vendored");
78

89
// we can optimize the settings here, but some would require libvips
910
// to be compiled with additional stuff
@@ -130,6 +131,14 @@ async function processFile(fileName,
130131
if(fingerprint !== undefined) {
131132
writeOptions.fingerprint = fingerprint;
132133
}
134+
135+
let tags = await exiftool.read(sourcePath);
136+
let meta = {};
137+
if(tags) {
138+
meta.exif = tags;
139+
}
140+
141+
writeOptions.meta = meta;
133142
return assetManager.writeFile(targetPath, output, writeOptions);
134143
}
135144

@@ -178,7 +187,6 @@ async function optimizeBitmap(sourcePath, format,
178187
default:
179188
abort(`unsupported format ${format}. We support: AVIF, JPG, PNG, WebP, SVG`);
180189
}
181-
182190
return image.toBuffer();
183191
}
184192

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"homepage": "https://www.faucet-pipeline.org",
2222
"dependencies": {
23+
"exiftool-vendored": "^15.11.0",
2324
"faucet-pipeline-core": "^1.7.0",
2425
"sharp": "^0.30.1",
2526
"svgo": "^2.8.0"

0 commit comments

Comments
 (0)