1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

fix: Preserve orientation of images

Closes #384
This commit is contained in:
Maksim Eltyshev 2023-01-17 22:14:39 +01:00
parent d420f6cb27
commit 0f50dbde92
4 changed files with 34 additions and 12 deletions

View file

@ -26,7 +26,7 @@ module.exports = {
fs.mkdirSync(rootPath);
await moveFile(inputs.file.fd, filePath);
const image = sharp(filePath, {
let image = sharp(filePath, {
animated: true,
});
@ -46,7 +46,11 @@ module.exports = {
const thumbnailsPath = path.join(rootPath, 'thumbnails');
fs.mkdirSync(thumbnailsPath);
const { width, pageHeight: height = metadata.height } = metadata;
let { width, pageHeight: height = metadata.height } = metadata;
if (metadata.orientation && metadata.orientation > 4) {
[image, width, height] = [image.rotate(), height, width];
}
const isPortrait = height > width;
const thumbnailsExtension = metadata.format === 'jpeg' ? 'jpg' : metadata.format;