Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using mozjpeg to compress pictures will result in errors! #338

Closed
JohnApache opened this issue Jan 17, 2020 · 5 comments
Closed

Using mozjpeg to compress pictures will result in errors! #338

JohnApache opened this issue Jan 17, 2020 · 5 comments

Comments

@JohnApache
Copy link

  • Node Version: 11.15.0
  • Imagemin Version: 7.0.1
  • Gulp-Imagemin Version: 7.0.0
    Imagemin 7.0.0 ^ compress JPEG pictures with mozjpeg。
    When I use mozjpeg to compress JPEG images, the tool throws an exception. But pictures in other formats are normally compressed.
import imagemin from 'gulp-imagemin';
const ImageTask = () => {
    return src(['src/images/*.{png,jpg,jpeg,svg,gif}'])
            .pipe(imagemin(
                [
                    imagemin.gifsicle({
                        interlaced: true,
                        optimizationLevel: 3,
                    }),
                    imagemin.mozjpeg({
                        quality: 75,
                        progressive: true
                    }),
                    imagemin.optipng({ optimizationLevel: 5}),
                    imagemin.svgo(),
                ], {
                    silent: false
                }
            ))
            .pipe(dest('dist/images'))
}

The details of the error are as follows

Message:
    spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg ENOENT
Details:
    errno: ENOENT
    code: ENOENT
    syscall: spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
    path: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
    spawnargs: 
    stdout: 
    stderr: 
    failed: true
    signal: null
    cmd: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
    timedOut: false
    killed: false
    fileName: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/src/images/20171219195409_ez4Vu.jpeg
    domainEmitter: [object Object]
    domainThrown: false

I try to use mozjpeg command directly,like this

npx mozjpeg --help

Exception will still be thrown.

spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg ENOENT

When I reduce imagemin to 6.2.0,Imagemin 6.2.0 compress JPEG pictures with jpegtran, and there's no problem with jpegtran.

I hope this problem can be solved.

@jmarshall9120
Copy link

@JohnApache - I'm experiencing this same issue. What was your final resolution? Would you mind sharing how its been working out over the last year?

@carlosesierra
Copy link

carlosesierra commented Mar 12, 2021

similar issue here :(

"gulp-imagemin": "^7.1.0",

gulp-imagemin: Couldn't load default plugin "gifsicle"

Message:
spawn /Users/hello/Desktop/carlos.sierra/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg ENOENT
Details:
errno: -2
code: ENOENT
syscall: spawn /Users/hello/Desktop/carlos/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg
path: /Users/hello/Desktop/carlos/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg
spawnargs:
stdout:
stderr:
failed: true
signal: null
cmd: /Users/hello/Desktop/carlos/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg
timedOut: false
killed: false
fileName: /Users/hello/Desktop/carlos/banners/beta/0001/src/items/300x600/img/bg.jpg
domainEmitter: [object Object]
domainThrown: false

@tangkunyin
Copy link

tangkunyin commented Apr 19, 2021

In my case, the problem occurred after I upgrade npm to latest version(7.10.0). At first, I run rm -rf node_modules && npm install but it does't work at all.....

Then I try to check the mozjpeg folder and I found there was no vender/cjpeg. So I try to install packages whith yarn install and at last it works

For more details: npm/cli#1905 npm/cli#3100

image

@joson
Copy link

joson commented Jun 1, 2021

I've resolved this problem by fixing the error while install gulp-imageimge.
I reinstalled gulp-imageimge, and found that the mozjpeg had been installed but couldn't be compiled well. And then the installation passed through quickly, so that you might not take notice of the error message.
The error message to me was a lib named 'nasm' was missing. I installed it on my Linux OS. Then it can be reinstalled well.
npm version: 6.14

@pm0u
Copy link

pm0u commented Nov 9, 2022

This seems to be an error with npm >= 7, we were able to get past this with npm install -g npm@6 although really not sure why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants