From b531cf2cced3548db3b5028445327b3fc53a5dfe Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Tue, 18 Mar 2025 09:18:01 +0700 Subject: [PATCH] UBERF-9637 Fix: prevent sharp rotating image on resize (#8256) Signed-off-by: Alexander Onnikov --- server/front/src/index.ts | 3 +++ services/datalake/pod-datalake/src/handlers/image.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/server/front/src/index.ts b/server/front/src/index.ts index c1089e264d..9a49eb950e 100644 --- a/server/front/src/index.ts +++ b/server/front/src/index.ts @@ -926,6 +926,9 @@ async function getGeneratePreview ( } sharp.cache(false) + // auto orient image based on exif to prevent resize use wrong orientation + pipeline = pipeline.rotate() + pipeline = pipeline.resize({ width: size, fit: 'cover', diff --git a/services/datalake/pod-datalake/src/handlers/image.ts b/services/datalake/pod-datalake/src/handlers/image.ts index a40c17dc58..b62419f8e4 100644 --- a/services/datalake/pod-datalake/src/handlers/image.ts +++ b/services/datalake/pod-datalake/src/handlers/image.ts @@ -105,6 +105,10 @@ export async function handleImageGet ( await writeFile(tmpFile, blob.body) let pipeline = sharp(tmpFile) + + // auto orient image based on exif to prevent resize use wrong orientation + pipeline = pipeline.rotate() + pipeline.resize({ width, height,