0
我使用了所有支持灰度级的npm包,但没有任何工作正常。其中一些正在工作,但质量下降。 有一个很好的灰度包名为图像灰度,但问题是,当其中一个src图像(example/image.gpg)文件被破坏,然后根据承诺代码停止进一步。 下面的代码是问题所在。如何在节点j中将彩色图像(jpg,jpeg,png)更改为黑白或灰度
globby(['./upload/*.*','!./upload/*.ico','!./upload/*.gif', '!./upload/*.txt']).then(function (paths) {
return Promise.all(paths.map(function (e) {
return imageGrayScale(e, {logProgress: 1}) }));
}).then(function (val) {
// if one of the file in directory is corrupted then promise is rejected and my code stooped and i cant do anything further
})
请告诉我如何处理错误的诺言代码走得更远。或者有没有像回调的解决方案。
我应该去任何其他模块,也可以写自己的algorithim灰度,请告诉我如何图像的颜色转换成黑白