mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-10 01:15:06 +02:00
Added an endpoint to serve different cover sizes
This commit is contained in:
parent
c92175cdc7
commit
69fa00608f
3 changed files with 42 additions and 0 deletions
16
server/utils/resizeImage.js
Normal file
16
server/utils/resizeImage.js
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue