From 8299fd24ec02200d774c53a340deaf7e19fc25de Mon Sep 17 00:00:00 2001 From: Stefan Forstenlechner Date: Sun, 10 Apr 2022 17:40:47 +0200 Subject: [PATCH] Consider orientation --- picture-gallery-server/src/app.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/picture-gallery-server/src/app.ts b/picture-gallery-server/src/app.ts index beec04b..1ce87a5 100644 --- a/picture-gallery-server/src/app.ts +++ b/picture-gallery-server/src/app.ts @@ -25,10 +25,11 @@ app.get("/api(/*)?", (req, res) => { .filter((f) => f.isFile()) .map((f) => { const dimensions = sizeOf(`${publicPath}${requestedPath}/${f.name}`); + const widthAndHeightSwap = dimensions.orientation > 4; // see https://exiftool.org/TagNames/EXIF.html return { src: `/images${normalizedPath}/${f.name}`, - width: dimensions.width, - height: dimensions.height, + width: widthAndHeightSwap ? dimensions.height : dimensions.width, + height: widthAndHeightSwap ? dimensions.width : dimensions.height, }; });