Modifier la taille de l'image redimensionnée à un septième de ses dimensions d'origine et ajuster la qualité JPEG

This commit is contained in:
2025-03-10 16:41:50 +01:00
parent a15ebb0697
commit 37d82d1133

View File

@@ -183,12 +183,13 @@ router.get('/preview/:projectId/:orderId', async (req, res) => {
// Obtenir les dimensions originales de l'image
const metadata = await sharp(imagePath).metadata();
const width = Math.floor(metadata.width / 5);
const height = Math.floor(metadata.height / 5);
const width = Math.floor(metadata.width / 7);
const height = Math.floor(metadata.height / 7);
// Redimensionner l'image à la moitié de ses dimensions d'origine
const resizedImage = await sharp(imagePath)
.resize(width, height)
.jpeg({ quality: 65 })
.toBuffer();
res.set('Content-Type', 'image/jpeg');