aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/image-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/image-utils.ts')
-rw-r--r--server/helpers/image-utils.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
index 206cfa5bc..4305584d5 100644
--- a/server/helpers/image-utils.ts
+++ b/server/helpers/image-utils.ts
@@ -76,8 +76,11 @@ async function autoResize (options: {
76}) { 76}) {
77 const { sourceImage, newSize, destination } = options 77 const { sourceImage, newSize, destination } = options
78 78
79 // Portrait mode, special handling 79 // Portrait mode targetting a landscape, apply some effect on the image
80 if (sourceImage.getWidth() < sourceImage.getHeight()) { 80 const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight()
81 const destIsPortraitOrSquare = newSize.width <= newSize.height
82
83 if (sourceIsPortrait && !destIsPortraitOrSquare) {
81 const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) 84 const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height)
82 .color([ { apply: 'shade', params: [ 50 ] } ]) 85 .color([ { apply: 'shade', params: [ 50 ] } ])
83 86
@@ -86,7 +89,7 @@ async function autoResize (options: {
86 return write(baseImage.blit(topImage, 0, 0), destination) 89 return write(baseImage.blit(topImage, 0, 0), destination)
87 } 90 }
88 91
89 return write(sourceImage.contain(newSize.width, newSize.height), destination) 92 return write(sourceImage.cover(newSize.width, newSize.height), destination)
90} 93}
91 94
92function write (image: Jimp, destination: string) { 95function write (image: Jimp, destination: string) {