X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fimage-utils.ts;h=4305584d58f962727726a6cc35b03bf857e2111e;hb=63a3d336f6cc9a293a07fdc12d6bdfb86cfc2fd5;hp=206cfa5bc7198824defcd23ade2e1b8b535c224e;hpb=7196a70b28e93ede11ccbfef7f1bc919c663b964;p=github%2FChocobozzz%2FPeerTube.git 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: { }) { const { sourceImage, newSize, destination } = options - // Portrait mode, special handling - if (sourceImage.getWidth() < sourceImage.getHeight()) { + // Portrait mode targetting a landscape, apply some effect on the image + const sourceIsPortrait = sourceImage.getWidth() < sourceImage.getHeight() + const destIsPortraitOrSquare = newSize.width <= newSize.height + + if (sourceIsPortrait && !destIsPortraitOrSquare) { const baseImage = sourceImage.cloneQuiet().cover(newSize.width, newSize.height) .color([ { apply: 'shade', params: [ 50 ] } ]) @@ -86,7 +89,7 @@ async function autoResize (options: { return write(baseImage.blit(topImage, 0, 0), destination) } - return write(sourceImage.contain(newSize.width, newSize.height), destination) + return write(sourceImage.cover(newSize.width, newSize.height), destination) } function write (image: Jimp, destination: string) {