mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 00:07:17 +00:00
Respect metadata removal switch
This commit is contained in:
parent
89390b3fc5
commit
e010fe47cc
2 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue