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));
私は以下のようなイメージエラーを使用すると、何か迷ったのですか?イメージエラー[TypeError :(入力、出力、opts)=> {
[TypeError: (input, output, opts) => {
if (!Array.isArray(input)) {
return Promise.reject(new TypeError('Expected an arr...<omitted>...
} is not a constructor]
ありがとうを動作します! :D – Despertaweb