Sharp: libimagequant is installed but Sharp doesn't recognize it

Created on 28 Mar 2019  路  6Comments  路  Source: lovell/sharp

Libimagequant was installed from on Debian:

apt-get install libimagequant0

But the options.palette, options.quality, etc, doesn't work.

Some help to put Sharp working with Libimagequant?

question

All 6 comments

You'll need to compile libvips with support for libimagequant and install it globally, then reinstall sharp.

How to check if Sharp are using libimagequant?

I already complile libvips with support for libimagequant with:

./configure --with-jpeg-includes=/usr/lib --with-jpeg-libraries=/usr/lib --with-png-libraries=/usr/lib --with-png-includes=/usr/lib

But I don't if sharp are using it correctly.

I'm using this script (https://github.com/jcupitt/docker-builds/blob/master/libvips-mozjpeg-ubuntu18.10/Dockerfile) to install mozjpeg and libvips and after just do npm install to install dependencies of my script.

But this is not enough to put sharp working with mozjpeg.

What am I doing wrong?

When you run npm install sharp it will tell you if it found a globally-installed libvips.

ldd node_modules/sharp/build/Release/sharp.node will list the runtime dependencies.

@lovell can you help me to understand what I are doing wrong to install the sharp with mozjpeg on Debian?

apt-get update && apt-get install -y build-essential autoconf automake libtool nasm unzip wget pkg-config
cd /usr/local/src && wget https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz && tar xzf v3.3.1.tar.gz
cd /usr/local/src/mozjpeg-3.3.1 && aclocal && autoconf && autoheader && libtoolize && automake --add-missing && ./configure && make && make install
apt-get install -y libglib2.0-dev libexpat-dev libpng-dev libgif-dev libexif-dev liblcms2-dev liborc-dev

export PKG_CONFIG_PATH=/opt/mozjpeg/lib64/pkgconfig
export LD_LIBRARY_PATH=/usr/local/lib

cd /usr/local/src && wget https://github.com/libvips/libvips/releases/download/v8.7.4/vips-8.7.4.tar.gz && tar xzf vips-8.7.4.tar.gz 
cd /usr/local/src/vips-8.7.4 && CFLAGS=-O3 CXXFLAGS=-O3 ./configure && make && make install

After that tried to install Sharp (npm install) and get this error:

info sharp Detected globally-installed libvips v8.7.4
info sharp Building from source via node-gyp
Package libjpeg was not found in the pkg-config search path.
Perhaps you should add the directory containing `libjpeg.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libjpeg', required by 'vips', not found
gyp: Call to 'PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.9.0-8-amd64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pedro/image-server/node_modules/sharp
gyp ERR! node -v v8.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-31T16_56_48_779Z-debug.log
ldd `which vips` | grep jpeg
libjpeg.so.62 => /opt/mozjpeg/lib64/libjpeg.so.62 (0x00007f131ea6c000)
echo $PKG_CONFIG_PATH
/opt/mozjpeg/lib64/pkgconfig/
cd /opt/mozjpeg/lib64/pkgconfig/
root@ic-images:/opt/mozjpeg/lib64/pkgconfig# ls
libjpeg.pc  libturbojpeg.pc

Are you sure PKG_CONFIG_PATH was set when calling npm install? I would expect to see your custom value listed in the following log entry, which currently includes only default values:

gyp: Call to 'PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config ...
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaekunchoi picture jaekunchoi  路  3Comments

genifycom picture genifycom  路  3Comments

OleVik picture OleVik  路  3Comments

natural-law picture natural-law  路  3Comments

henbenla picture henbenla  路  3Comments