function minBytes(originalFilePath, destinationFilePath) {
return new Promise(function (resolve, reject){
var Imagemin = require('imagemin');
console.log(originalFilePath) // /app/public/images/temporary/4du_QIGCJb5.jpeg
console.log(destinationFilePath) // /app/public/images/database/9d605a80a2cf926513b7fb/4du_QIGCJb5-0.jpeg
var imagemin = new Imagemin()
.src(originalFilePath)
.dest(destinationFilePath);
imagemin.run(function (error, files) {
if (error != null) {
console.log(error)
reject(error);
} else {
console.log(files);
resolve(destinationFilePath);
}
});
});
};
var minBytesResult = yield Promise.resolve( minBytes(originalFilePath, destinationFilePath) );
当我使用如下的imagemin get error时,我错过了什么吗?
[TypeError: (input, output, opts) => {
if (!Array.isArray(input)) {
return Promise.reject(new TypeError('Expected an arr...<omitted>...
} is not a constructor]
最佳答案
这是使用imagemin的v4.0.0方法。
安装:npm install [email protected]
,您的代码即可使用
关于javascript - imagemin error [TypeError:(input,output,opts)=> {,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38134549/