admin settings fix #12, fix #13 image in mastodon

This commit is contained in:
lesion
2019-03-12 01:16:52 +01:00
parent 9702f93cf9
commit c5989fa8b4
23 changed files with 232 additions and 85 deletions

View File

@@ -23,10 +23,10 @@ DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) {
that.getDestination(req, file, function (err, destination) {
if (err) return cb(err)
const filename = crypto.randomBytes(16).toString('hex') + '.webp'
const filename = crypto.randomBytes(16).toString('hex') + '.jpg'
const finalPath = path.join(destination, filename)
const outStream = fs.createWriteStream(finalPath)
const resizer = sharp().resize(800).webp()
const resizer = sharp().resize(800).jpeg({ quality: 80 })
file.stream.pipe(resizer).pipe(outStream)
outStream.on('error', cb)