sharp是最快的 Node.js 模块用于调整 JPEG, PNG, WebP 和 TIFF 图片大小。使用libvips库实现。JPEG调整大小的性能通常比ImageMagick和GraphicsMagick快8倍,主要是根据CPU核心可用数。
var sharp = require('sharp');
sharp('input.jpg').resize(300, 200).toFile('output.jpg', function(err) {
if (err) {
throw err;
}
// output.jpg is a 300 pixels wide and 200 pixels high image
// containing a scaled and cropped version of input.jpg
});