mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
don't call .jpeg quality on pngs
This commit is contained in:
@@ -32,19 +32,23 @@ image.resizeImage = function (data, callback) {
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
var sharpImage;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
fs.readFile(data.path, next);
|
||||
},
|
||||
function (buffer, next) {
|
||||
var sharp = requireSharp();
|
||||
var sharpImage = sharp(buffer, {
|
||||
sharpImage = sharp(buffer, {
|
||||
failOnError: true,
|
||||
});
|
||||
sharpImage.metadata(next);
|
||||
},
|
||||
function (metadata, next) {
|
||||
sharpImage.rotate(); // auto-orients based on exif data
|
||||
sharpImage.resize(data.hasOwnProperty('width') ? data.width : null, data.hasOwnProperty('height') ? data.height : null);
|
||||
|
||||
if (data.quality) {
|
||||
if (data.quality && metadata.format === 'jpeg') {
|
||||
sharpImage.jpeg({ quality: data.quality });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user