无法使用 imageminMozjpeg 压缩大文件?

Unable to compress large file with imageminMozjpeg?

我一直在节点上制作一个服务器,它可以将图像文件压缩后上传到磁盘上。 但是,正在压缩较小尺寸的图像,而尺寸较大(如 10mb 左右)的图像会出现以下错误。

 { Error: Error in file: ./uploads/ecqrwxgz6lw.jpg

write EOF
    at _errnoException (util.js:1024:11)
    at WriteWrap.afterWrite [as oncomplete] (net.js:867:14)
  code: 'EOF',
  errno: 'EOF',
  syscall: 'write',
  killed: false,
  stdout: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff e1 ff fe 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 0d 00 0f 01 02 00 12 00 00 00 ac 00 ... >,
  stderr: <Buffer >,
  failed: true,
  signal: null,
  cmd: 'D:\Projects\web-development\Node.js\Business\node_modules\mozjpeg\vendor\cjpeg.exe -quality 60',
  timedOut: false }

我的multer上传文件的代码是

    var multer = require('multer');

var storage = multer.diskStorage({
    destination: function (req, file, callback) {

        callback(null, './uploads');
    },
    filename: function (req, file, callback) {
        var  rand = Math.random().toString(36).substr(2, 12);
        req.rand =  rand;
        ext = file.originalname.substring(file.originalname.lastIndexOf('.'), file.originalname.length);
        callback(null, rand+ext);
    }
});

var upload = multer({
    storage: storage
}).single('userPhoto');

module.exports = {
    upload: upload,
};

这是我上传文件的路径

    app.post('/events/upload', upload, function (req, res) {

    var fb_id = req.user.id;
    var email = req.user._json.email;
    var random = req.rand;

    console.log(fb_id);

    var query = {
            'Fbid': fb_id
        },
        update = {
            $set: {
                email: email
            },
            $push: {
                events: {
                    event: place,
                    imageId: random
                }
            }
        },
        options = {
            upsert: true
        };

    usersuploadImformation.findOneAndUpdate(query, update, options, function (err, data) {
        if (err) {
            console.log("Not able to update");
        }
        else{
            console.log("Updated");
        }
    });


    imagemin(['./uploads/'+random+'.{JPG,jpg}'], './uploads', {
        plugins: [
            imageminMozjpeg({
                              quality: 60,
                              progressive: true

                             })
        ]
    }).then(files => {
        console.log(files);
        //=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …] 
    }).catch((err)=>{
        console.log(err);
    });



});

刚刚用了另一个压缩插件,这是imageminmozjpeg的bug。 我使用了 imageminJpegRecompress