Linux HOWTOs

About | Home | Search


HOWTO: libimagequant
Description: Image quantization library
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# libimagequant 2.12.2
# ====================
# If you want a command-line utility for this library, see pngquant

# Get it
cd
test -f installed/libimagequant-2.12.2.tar.gz &&
 mv -f installed/libimagequant-2.12.2.tar.gz .
test ! -f libimagequant-2.12.2.tar.gz &&
 wget -O libimagequant-2.12.2.tar.gz \
  https://github.com/ImageOptim/libimagequant/archive/2.12.2.tar.gz

# Extract it
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "libimagequant-*" -exec rm -r {} \;
tar xzvf ~/libimagequant-2.12.2.tar.gz
cd libimagequant-2.12.2
test $UID = 0 && chown -R root:root .

# Read ./README.md

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
 ./configure --libdir=/usr/local/lib64 \
  --pkgconfigdir=/usr/local/lib64/pkgconfig

# Configure the build for anything else
test $(uname -m) != 'x86_64' && ./configure

# 'make imagequant.pc' does not use libdir passed to configure, so
# update the .in file if 64-bit.  If you're not sure what it should be,
# it is whatever LIBDIR in config.mk is set to.
# Verify changes with 'diff -u imagequant.pc.in imagequant.pc'
test $(uname -m) = 'x86_64' &&
 cat imagequant.pc.in | \
  sed -e 's|\${prefix}/lib$|\${prefix}/lib64|' \
      -e 's|PREFIX|/usr/local|' \
      -e 's|VERSION|2.12.2|' > imagequant.pc

# Not 64-bit, generate imagequant.pc the usual way
test $(uname -m) != 'x86_64' && make imagequant.pc

# Build it (only) as a shared library
make libimagequant.so

# Become root to install it
su

# Install it
install -m 644 libimagequant.h /usr/local/include/libimagequant.h
install -m 644 libimagequant.so.0 /usr/local/lib64/libimagequant.so.0
( cd /usr/local/lib64 ; ln -sf libimagequant.so.0 libimagequant.so )
install -m 644 imagequant.pc /usr/local/lib64/pkgconfig/imagequant.pc
ldconfig

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/libimagequant-*.tar.*
mv -f libimagequant-2.12.2.tar.gz installed/


# If you ever want to uninstall libimagequant, this should do it:
cd
su
test -d src/libimagequant-* && ( cd src/libimagequant-* ; make uninstall )
rm -f /usr/local/include/libimagequant.h \
 /usr/local/lib64/libimagequant.* \
 /usr/local/lib64/pkgconfig/imagequant.pc
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libimagequant-*" -exec rm -r {} \;
rm -f ~/installed/libimagequant-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>