Added an endpoint to serve different cover sizes

This commit is contained in:
Keagan Hilliard 2021-12-12 08:52:27 -08:00
parent c92175cdc7
commit 69fa00608f
3 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,16 @@
const sharp = require('sharp')
const fs = require('fs')
function resize(filePath, width, height) {
const readStream = fs.createReadStream(filePath);
let sharpie = sharp()
sharpie.toFormat('jpeg')
if (width || height) {
sharpie.resize(width, height)
}
return readStream.pipe(sharpie)
}
module.exports = resize;