Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Better conversion to square thumbnail

Chocobozzz9de18b4c13fb
diff --git a/server/core/helpers/image-utils.ts b/server/core/helpers/image-utils.ts
index b42476e650..e1471e6be1 100644
--- a/server/core/helpers/image-utils.ts
+++ b/server/core/helpers/image-utils.ts
@@ -117,11 +117,16 @@ async function autoResize (options: {
}) {
const { sharpInstance, metadata, newSize, destination } = options
- // Portrait mode targeting a landscape, apply some effect on the image
- const sourceIsPortrait = metadata.width <= metadata.height
+ // Portrait/square input to landscape target
+ const sourceIsPortraitOrSquare = metadata.width <= metadata.height
const destIsPortraitOrSquare = newSize.width <= newSize.height
- if (sourceIsPortrait && !destIsPortraitOrSquare) {
+ // Portrait source to landscape destination
+ // Or portrait source to landscape destination
+ if (
+ (sourceIsPortraitOrSquare && !destIsPortraitOrSquare) ||
+ (!sourceIsPortraitOrSquare && destIsPortraitOrSquare)
+ ) {
const foregroundImage = sharpInstance.clone()
.resize(newSize.width, newSize.height, { fit: 'inside' })