Fix too thin images

This commit is contained in:
xmflsct 2023-01-15 22:04:25 +01:00
parent b52b529550
commit 34c0bbf4bb
1 changed files with 9 additions and 4 deletions

View File

@ -9,7 +9,12 @@ export const aspectRatio = ({
width?: number width?: number
height?: number height?: number
}): number => { }): number => {
const cropTooTall = (height || 1) / (width || 1) > 3 / 2 ? 2 / 3 : (width || 1) / (height || 1) const defaultCrop =
(height || 1) / (width || 1) > 3 / 2
? 2 / 3
: (width || 1) / (height || 1) > 4
? 4
: (width || 1) / (height || 1)
const isEven = total % 2 == 0 const isEven = total % 2 == 0
if (total > 5) { if (total > 5) {
@ -26,12 +31,12 @@ export const aspectRatio = ({
} else { } else {
switch (isEven) { switch (isEven) {
case true: case true:
return cropTooTall return defaultCrop
case false: case false:
if ((index || -2) + 1 == total) { if ((index || -2) + 1 == total) {
return cropTooTall * 2 return defaultCrop * 2
} else { } else {
return cropTooTall return defaultCrop
} }
} }
} }