mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
Replace jimp with sharp (#6774)
* add probe image size and max image size * replace jimp and image-probe with sharp * better name for test * resize with just path * resize thumb inplace * use filename
This commit is contained in:
committed by
GitHub
parent
69c7260fe9
commit
b7ead6dc9c
@@ -2,7 +2,6 @@
|
||||
|
||||
var async = require('async');
|
||||
var path = require('path');
|
||||
var Jimp = require('jimp');
|
||||
var mime = require('mime');
|
||||
|
||||
var db = require('../database');
|
||||
@@ -27,7 +26,6 @@ module.exports = function (Groups) {
|
||||
var tempPath = data.file ? data.file : '';
|
||||
var url;
|
||||
var type = data.file ? mime.getType(data.file) : 'image/png';
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (tempPath) {
|
||||
@@ -49,7 +47,10 @@ module.exports = function (Groups) {
|
||||
Groups.setGroupField(data.groupName, 'cover:url', url, next);
|
||||
},
|
||||
function (next) {
|
||||
resizeCover(tempPath, next);
|
||||
image.resizeImage({
|
||||
path: tempPath,
|
||||
width: 358,
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
uploadsController.uploadGroupCover(uid, {
|
||||
@@ -74,22 +75,6 @@ module.exports = function (Groups) {
|
||||
});
|
||||
};
|
||||
|
||||
function resizeCover(path, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
new Jimp(path, next);
|
||||
},
|
||||
function (image, next) {
|
||||
image.resize(358, Jimp.AUTO, next);
|
||||
},
|
||||
function (image, next) {
|
||||
image.write(path, next);
|
||||
},
|
||||
], function (err) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
Groups.removeCover = function (data, callback) {
|
||||
db.deleteObjectFields('group:' + data.groupName, ['cover:url', 'cover:thumb:url', 'cover:position'], callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user