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
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 \

# 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 ./

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

# 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 is set to.
# Verify changes with 'diff -u imagequant.pc'
test $(uname -m) = 'x86_64' &&
 cat | \
  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

# Become root to install it

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

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

# Become yourself again

# Save the source for later
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:
test -d src/libimagequant-* && ( cd src/libimagequant-* ; make uninstall )
rm -f /usr/local/include/libimagequant.h \
 /usr/local/lib64/libimagequant.* \
find ~/src -maxdepth 1 -type d -name "libimagequant-*" -exec rm -r {} \;
rm -f ~/installed/libimagequant-*.tar.*

Back to the list

Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>