aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-16 16:11:10 +0100
committerChocobozzz <me@florianbigard.com>2021-11-16 16:11:10 +0100
commit9c7cf0072ffbfff7e1d3276af9123d9c5a3a0aa6 (patch)
treea422a80bbb41dd0b2da1e6faee8aa166faf46fb4
parent7196a70b28e93ede11ccbfef7f1bc919c663b964 (diff)
downloadPeerTube-9c7cf0072ffbfff7e1d3276af9123d9c5a3a0aa6.tar.gz
PeerTube-9c7cf0072ffbfff7e1d3276af9123d9c5a3a0aa6.tar.zst
PeerTube-9c7cf0072ffbfff7e1d3276af9123d9c5a3a0aa6.zip
Prefer cover instead of contain for images
-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) {