Consider orientation

This commit is contained in:
Stefan Forstenlechner 2022-04-10 17:40:47 +02:00
parent 8eef6da351
commit 8299fd24ec
1 changed files with 3 additions and 2 deletions

View File

@ -25,10 +25,11 @@ app.get("/api(/*)?", (req, res) => {
.filter((f) => f.isFile()) .filter((f) => f.isFile())
.map((f) => { .map((f) => {
const dimensions = sizeOf(`${publicPath}${requestedPath}/${f.name}`); const dimensions = sizeOf(`${publicPath}${requestedPath}/${f.name}`);
const widthAndHeightSwap = dimensions.orientation > 4; // see https://exiftool.org/TagNames/EXIF.html
return { return {
src: `/images${normalizedPath}/${f.name}`, src: `/images${normalizedPath}/${f.name}`,
width: dimensions.width, width: widthAndHeightSwap ? dimensions.height : dimensions.width,
height: dimensions.height, height: widthAndHeightSwap ? dimensions.width : dimensions.height,
}; };
}); });