fix: télécharger l'image avant traitement Sharp pour les stories avec texte

This commit is contained in:
Michael committed 2026-01-20 11:34:59 +01:00
1 parent 4f8bab176a
commit b38f082d6e
2 files changed
+18 -13

No files matched your search

+8 -1
View File
@@ -125,8 +125,15 @@ export class ImageProcessor {
// Remove hashtags from text while keeping emojis
const cleanText = removeHashtags(text);
// Download image from URL first (Sharp can't read URLs directly)
const imageResponse = await fetch(imageUrl);
if (!imageResponse.ok) {
throw new Error(`Failed to fetch image from URL: ${imageUrl}`);
}
const imageBuffer = Buffer.from(await imageResponse.arrayBuffer());
// Pre-process image with sharp to apply rotation
const rotationBuffer = await sharp(imageUrl)
const rotationBuffer = await sharp(imageBuffer)
.rotate() // Apply EXIF rotation
.toBuffer();