2
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, получаю ошибку, как показано ниже, я что-то пропустил?imagemin error [TypeError: (input, output, opts) => {
[TypeError: (input, output, opts) => {
if (!Array.isArray(input)) {
return Promise.reject(new TypeError('Expected an arr...<omitted>...
} is not a constructor]
Thanx @tsouza вы спасли меня !! : D – Despertaweb