1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59: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 fab623bb52
commit 6fd42e3b62
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;

View file

@ -17,7 +17,7 @@ module.exports = {
},
async fn(inputs) {
const image = sharp(inputs.file.fd, {
let image = sharp(inputs.file.fd, {
animated: true,
});
@ -37,7 +37,11 @@ module.exports = {
fs.mkdirSync(rootPath);
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 extension = metadata.format === 'jpeg' ? 'jpg' : metadata.format;
try {

View file

@ -17,7 +17,7 @@ module.exports = {
},
async fn(inputs) {
const image = sharp(inputs.file.fd, {
let image = sharp(inputs.file.fd, {
animated: true,
});
@ -37,7 +37,11 @@ module.exports = {
fs.mkdirSync(rootPath);
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 extension = metadata.format === 'jpeg' ? 'jpg' : metadata.format;
try {