mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-06 10:42:44 +02:00
Added an endpoint to serve different cover sizes
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user