Respect metadata removal switch

This commit is contained in:
Nachtalb 2021-04-13 20:45:16 +02:00
parent 89390b3fc5
commit e010fe47cc
No known key found for this signature in database
GPG key ID: E48DF13C07055D92
2 changed files with 11 additions and 0 deletions

View file

@ -180,6 +180,7 @@ class Uploader {
};
const formData = new FormData();
formData.append("removeMetadata", store.state.settings.removeImageMetadata);
formData.append("file", file);
this.xhr.open("POST", `uploads/new/${token}`);
this.xhr.send(formData);

View file

@ -130,6 +130,7 @@ class Uploader {
let destDir;
let destPath;
let streamWriter;
let removeMetadata;
const doneCallback = () => {
// detach the stream and drain any remaining data
@ -207,6 +208,11 @@ class Uploader {
busboyInstance.on("partsLimit", () => abortWithError(Error("Parts limit reached")));
busboyInstance.on("filesLimit", () => abortWithError(Error("Files limit reached")));
busboyInstance.on("fieldsLimit", () => abortWithError(Error("Fields limit reached")));
busboyInstance.on("field", (fieldname, val) => {
if (fieldname === "removeMetadata") {
removeMetadata = val === "true";
}
});
// generate a random output filename for the file
// we use do/while loop to prevent the rare case of generating a file name
@ -260,6 +266,10 @@ class Uploader {
sequentialRead: true,
});
if (!removeMetadata) {
sharpInstance = sharpInstance.withMetadata();
}
sharpInstance
.rotate() // auto-orient based on the EXIF Orientation tag
.toFile(destPath, (err) => {