don't call .jpeg quality on pngs

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 38ca8b481c
commit a73bcabad8

@ -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 });
}

Loading…
Cancel
Save