Auto rotate images based on exif orientation

This makes sure that the orientation of the images work in all viewrs.
This commit is contained in:
Nachtalb 2021-04-01 19:43:17 +02:00
parent 846da41b01
commit c2c66031c0
No known key found for this signature in database
GPG Key ID: E48DF13C07055D92
2 changed files with 7 additions and 9 deletions

View File

@ -246,13 +246,7 @@
type="checkbox"
name="removeImageMetadata"
/>
Attempt to remove metadata from images before uploading
<span
class="tooltipped tooltipped-n tooltipped-no-delay"
aria-label="This option will removes metadata from images and animated wepb files. This may break the images orientation."
>
<button class="extra-help" />
</span>
Remove metadata from uploaded images
</label>
</div>
</div>

View File

@ -251,8 +251,12 @@ class Uploader {
chunks.push(chunk);
})
.on("end", () => {
const buffer = Buffer.concat(chunks);
sharp(buffer, {animated: true, pages: -1, sequentialRead: true})
sharp(Buffer.concat(chunks), {
animated: true,
pages: -1,
sequentialRead: true,
})
.rotate() // auto-orient based on the EXIF Orientation tag
.toFile(destPath) // Removes metadata by default https://sharp.pixelplumbing.com/api-output#tofile
.catch(abortWithError);
});