mozjpeg进行压缩时失败

参考链接:

npm安装包时报错npm ERR! Failed at the gifsicle@4.0.1 postinstall script - 半亩方塘 (bluepost.cn)

(1条消息) mozjpeg 安装失败/Failed at the mozjpeg_imHere·的博客-CSDN博客_mozjpeg

npm install error 7.1.1 · Issue #67 · imagemin/mozjpeg-bin (github.com)

1.错误描述

在升级hexo的配置时,添加了压缩插件,但是出现了如下错误。

在具体分析时发现,并不是所有的图片都不能被压缩,而是只有部分图片不能被压缩。

FATAL {
  err: Error: write EOF
      at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
    errno: -4095,
    code: 'EOF',
    syscall: 'write',
    originalMessage: 'write EOF',
    shortMessage: 'Command failed with EOF: D:\\workspace\\myBlog\\node_modules\\_mozjpeg@7.1.1@mozjpeg\\vendor\\cjpeg.exe -baseline\n' +
      'write EOF',
    command: 'D:\\workspace\\myBlog\\node_modules\\_mozjpeg@7.1.1@mozjpeg\\vendor\\cjpeg.exe -baseline',
    exitCode: undefined,
    signal: undefined,
    signalDescription: undefined,
    stdout: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff e1 10 b2 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 02 87 69 00 04 00 00 00 01 00 00 ... 58228 more bytes>,
    stderr: <Buffer >,
    failed: true,
    timedOut: false,
    isCanceled: false,
    killed: false
  }
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

2.解决方法

(1条消息) mozjpeg 安装失败/Failed at the mozjpeg_imHere·的博客-CSDN博客_mozjpeg

无效,不过提供了hosts文件的模板。

npm install error 7.1.1 · Issue #67 · imagemin/mozjpeg-bin (github.com)

无效

(1条消息) mozjpeg上构建失败_高级盘丝洞的博客-CSDN博客

无效

在仔细检查时发现,jpeg文件不能被压缩。出现问题的图片如下所示:

4

最后将图片删除成功解决问题。

3.总结

最好使用png和jpg的图片格式,其他格式的图片很容易出现压缩问题。