Consider orientation
This commit is contained in:
parent
8eef6da351
commit
8299fd24ec
|
|
@ -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,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue