mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
16 lines
329 B
JavaScript
16 lines
329 B
JavaScript
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; |