1000ch / gulp-image

Optimize PNG, JPEG, GIF, SVG images with gulp task.
http://bit.ly/we-should-optimize-images
MIT License
223 stars 22 forks source link

Error on initialization: Library not loaded: /usr/local/lib/libjpeg.8.dylib #30

Closed baskinco closed 7 years ago

baskinco commented 7 years ago

gulp-image is responding with the error below. Any ideas what I've done wrong? Thanks!

In Gulpfile.js

gulp.task('imageoptim', function() { gulp.src(source + 'images/*.{jpg,JPG}') .pipe(image()) .pipe(gulp.dest(dest + 'images')); });

Error in terminal

(node:5308) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error in plugin 'gulp-image' Message: write EPIPE Details: code: EPIPE errno: EPIPE syscall: write killed: false stdout: stderr: dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib Referenced from: /Users/marc/localhost/ar_live/node_modules/jpegoptim-bin/vendor/jpegoptim Reason: image not found

failed: true
signal: null
cmd: /Users/marc/localhost/ar_live/node_modules/jpegoptim-bin/vendor/jpegoptim --strip-all --strip-iptc --strip-icc --stdin --stdout
timedOut: false
nlound commented 7 years ago

Can you show us the parameters on the inizalization of the plugin and the Also try setting

jpegoptim: false

Which version of Node and SO are you using?

1000ch commented 7 years ago

Would you try re-installing jpegoptim-bin? https://github.com/1000ch/gulp-image/issues/22#issuecomment-315613709

alexdrans commented 7 years ago

I had to run brew reinstall jpegoptim libpng mozjpeg to fix this

mortensassi commented 7 years ago

You can't just expect to download external dependencies in order to get your plugin to work. https://www.npmjs.com/package/gulp-imagemin is therefor the better choice

alexdrans commented 7 years ago

@moesphemie Whatever the issue is, I think it's with the underlying imagemin package which they both share. I had the same problem using gulp-imagemin

1000ch commented 7 years ago

As @alexdrans say, same problem will occur regardless of whether gulp-image or gulp-imagemin.

Executing brew reinstall jpegoptim libpng mozjpeg installs them dependencies by Homebrew, so you can install gulp-image including jpegoptim after executing it. I guess you don't need to install jpegoptim and mozjpeg themselves via Homebrew 🤔

You probably need to install libjpeg version 6b or later, alternatively libjpeg-turbo, would you try it if you have time. Thank you.

ifthenelse commented 7 years ago

It still throws an error after updating to libjpeg 9b:

(node:36379) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error in plugin 'gulp-image'
Message:
    write EPIPE
Details:
    code: EPIPE
    errno: EPIPE
    syscall: write
    killed: false
    stdout:
    stderr: dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim
  Reason: image not found

    failed: true
    signal: null
    cmd: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim --strip-all --strip-iptc --strip-icc --stdin --stdout
    timedOut: false
(node:36379) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error in plugin 'gulp-image'
Message:
    write EPIPE
Details:
    code: EPIPE
    errno: EPIPE
    syscall: write
    killed: false
    stdout:
    stderr: dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim
  Reason: image not found

    failed: true
    signal: null
    cmd: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim --strip-all --strip-iptc --strip-icc --stdin --stdout
    timedOut: false
(node:36379) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error in plugin 'gulp-image'
Message:
    write EPIPE
Details:
    code: EPIPE
    errno: EPIPE
    syscall: write
    killed: false
    stdout:
    stderr: dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim
  Reason: image not found

    failed: true
    signal: null
    cmd: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim --strip-all --strip-iptc --strip-icc --stdin --stdout
    timedOut: false
(node:36379) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 12): Error in plugin 'gulp-image'
Message:
    write EPIPE
Details:
    code: EPIPE
    errno: EPIPE
    syscall: write
    killed: false
    stdout:
    stderr: dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim
  Reason: image not found

    failed: true
    signal: null
    cmd: /projects/MyProject/node_modules/jpegoptim-bin/vendor/jpegoptim --strip-all --strip-iptc --strip-icc --stdin --stdout
    timedOut: false

I suppose that's because the plugin needs version 8.

ifthenelse commented 7 years ago

The error is thrown by jpegoptim-bin Solved via yarn upgrade jpegoptim-bin (or npm rebuild)

baskinco commented 7 years ago

Sorry for my VERY late response. @1000ch thank you. After installing jpegoptim-bin again the package works perfectly.