From 4b779838b355d29a5ca86ab70e69d0acfab07107 Mon Sep 17 00:00:00 2001 From: R0m1k3 Date: Wed, 14 Jan 2026 09:34:42 +0100 Subject: [PATCH] Fix: Pre-process Facebook story images with sharp to correct EXIF orientation --- server/services/imageProcessor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/services/imageProcessor.ts b/server/services/imageProcessor.ts index 5c8e0f7..ef34de1 100644 --- a/server/services/imageProcessor.ts +++ b/server/services/imageProcessor.ts @@ -125,10 +125,15 @@ export class ImageProcessor { // Remove hashtags from text while keeping emojis const cleanText = removeHashtags(text); + // Pre-process image with sharp to apply rotation + const rotationBuffer = await sharp(imageUrl) + .rotate() // Apply EXIF rotation + .toBuffer(); + const canvas = createCanvas(STORY_WIDTH, STORY_HEIGHT); const ctx = canvas.getContext('2d'); - const image = await loadImage(imageUrl); + const image = await loadImage(rotationBuffer); const imgWidth = image.width; const imgHeight = image.height;