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())
.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,
};
});