Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function(data) {
if (data.length === image.width * image.height * 3) {
data = rgb2rgba(data);
}
if (data.length !== image.width * image.height * 4) {
throw new Error('unexpected data length ' + data.length);
}
return new smartcrop.ImgData(image.width, image.height, data);
});
}
.toBuffer('RGBA', function(err, buffer) {
if (err) return reject(err);
resolve(new smartcrop.ImgData(image.width, image.height, buffer));
});
});