小编nap*_*ter的帖子

如何使用sharp包压缩PNG文件?

我正在尝试使用 node.js 锐利包压缩 PNG 文件(1MB 以上)。

var sharp = require('/usr/local/lib/node_modules/sharp');
sharp('IMG1.png')
.png({ compressionLevel: 9, adaptiveFiltering: true, force: true })
.withMetadata()
.toFile('IMG2.png', function(err){
    if(err){
        console.log(err);
    } else {
        console.log('done');
    }
}); 
Run Code Online (Sandbox Code Playgroud)

上面的代码不能正常工作。我有一个大约 3.5MB 的文件大小,我试图将它压缩到 1MB 左右。

image-processing node.js npm sharp

3
推荐指数
1
解决办法
4708
查看次数

标签 统计

image-processing ×1

node.js ×1

npm ×1

sharp ×1