mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-12-04 22:16:28 +01:00
Added an endpoint to serve different cover sizes
This commit is contained in:
1 parent
c92175cdc7
commit
69fa00608f
3 files changed
+42
No files matched your search
@@ -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