imagemin / imagemin-mozjpeg

Imagemin plugin for mozjpeg
MIT License
251 stars 57 forks source link

Incompatible library version: cjpeg #23

Open joepagan opened 7 years ago

joepagan commented 7 years ago

Hi,

I'm trying to run mozjpeg with gulp, but I get this error:

[00:13:17] Starting 'minify-jpgs'...

events.js:141
      throw er; // Unhandled 'error' event
      ^
Error: dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /Users/username/Documents/sites/website.com/node_modules/mozjpeg/vendor/cjpeg
  Reason: Incompatible library version: cjpeg requires version 36.0.0 or later, but libpng16.16.dylib provides version 27.0.0

    at ChildProcess.exithandler (child_process.js:203:12)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:817:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:469:12)

It manages to install ok, here is my task in full:

gulp.task("minify-jpgs", function(){
    return gulp.src([
        "./images/tester.jpg",
    ])
    .pipe(imagemin([
        imageminMozjpeg({
            progressive: true,
            quality: 80
        })
    ]))
    .pipe(gulp.dest("./images/mozjpeg"));
});

I am not sure what to do about this, can't find a similar issue anywhere. Do you have any suggestions?

aaronbushnell commented 7 years ago

Getting the same error, but not when using Gulp. It turned out that installing libpng via Homebrew corrected it.

brew install libpng

However, I'm not sure why this is happening. Does this package not also include this utility?

gbiryukov commented 7 years ago
$ brew upgrade libpng

resolved this issue for me

xiaoyaozi1010 commented 6 years ago

$ brew install libpng $ brew update libpng It's resolved, but the resolution is too inferior...

jdavidbakr commented 6 years ago

I'm getting this on an EC2 server, brew is not an option and I do have the latest libpng installed.

jdavidbakr commented 6 years ago

This is how I solved this issue on EC2, it seems that the proper version of libpng is not installed via yum. Downloading and compiling from source gives me the library I need.

git clone https://github.com/glennrp/libpng
cd libpng
./autogen.sh
./configure
make
make install
cd /usr/lib64/
ln -s /usr/local/lib/libpng16.so.16
ln -s /usr/local/lib/libpng16.so
colinodell commented 5 years ago

Upgrading to version 7 or higher of this library resolves the issue for me.