mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +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
@@ -25,7 +25,7 @@ uploadsController.upload = function (req, res, filesIterator) {
|
||||
files = files[0];
|
||||
}
|
||||
|
||||
async.map(files, filesIterator, function (err, images) {
|
||||
async.mapSeries(files, filesIterator, function (err, images) {
|
||||
deleteTempFiles(files);
|
||||
|
||||
if (err) {
|
||||
@@ -56,6 +56,9 @@ function uploadAsImage(req, uploadedFile, callback) {
|
||||
if (!canUpload) {
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
image.checkDimensions(uploadedFile.path, next);
|
||||
},
|
||||
function (next) {
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
return plugins.fireHook('filter:uploadImage', {
|
||||
image: uploadedFile,
|
||||
@@ -113,14 +116,9 @@ function resizeImage(fileObj, callback) {
|
||||
return callback(null, fileObj);
|
||||
}
|
||||
|
||||
var dirname = path.dirname(fileObj.path);
|
||||
var extname = path.extname(fileObj.path);
|
||||
var basename = path.basename(fileObj.path, extname);
|
||||
|
||||
image.resizeImage({
|
||||
path: fileObj.path,
|
||||
target: path.join(dirname, basename + '-resized' + extname),
|
||||
extension: extname,
|
||||
target: file.appendToFileName(fileObj.path, '-resized'),
|
||||
width: parseInt(meta.config.maximumImageWidth, 10) || 760,
|
||||
quality: parseInt(meta.config.resizeImageQuality, 10) || 60,
|
||||
}, next);
|
||||
@@ -157,7 +155,6 @@ uploadsController.uploadThumb = function (req, res, next) {
|
||||
var size = parseInt(meta.config.topicThumbSize, 10) || 120;
|
||||
image.resizeImage({
|
||||
path: uploadedFile.path,
|
||||
extension: path.extname(uploadedFile.name),
|
||||
width: size,
|
||||
height: size,
|
||||
}, next);
|
||||
|
||||
Reference in New Issue
Block a user