14 lines
494 B
JavaScript
14 lines
494 B
JavaScript
const sharp = require('sharp');
|
||
|
||
// Resize and center-crop an image to a 1:1 square at max 1000×1000, saved as JPEG.
|
||
// inputPath — absolute path of the source file (any format sharp supports)
|
||
// outputPath — absolute path for the output .jpg file
|
||
async function processCoverImage(inputPath, outputPath) {
|
||
await sharp(inputPath)
|
||
.resize(1000, 1000, { fit: 'cover', position: 'centre' })
|
||
.jpeg({ quality: 88 })
|
||
.toFile(outputPath);
|
||
}
|
||
|
||
module.exports = { processCoverImage };
|