Linux HOWTOs

About | Home | Search


HOWTO: imagemagick
Description: Convert, edit, and compose images
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


# ImageMagick
# ===========
# Slackware 13.37: imagemagick 6.6.6_10
# Slackware 14.0: imagemagick 6.7.7_10
# Slackware 14.1: imagemagick 6.8.6_10
# Slackware 14.2: imagemagick 6.9.4_9

# I include two different major versions of ImageMagick.  The latest 7.x
# and the latest 6.x - which I need because PHP's PECL imagick:
# https://pecl.php.net/package/imagick
# ...has not been updated since 2017-02 and does not appear to support
# ImageMagick 7.x, which was not yet released at the time.
#
# There is a separate HOWTO for PHP imagick

# A 'make uninstall' (as root) in the source dir of any old installed
# versions of ImageMagick might be a good idea.  If you skip down to the
# bottom, it covers that and manual removal of various things too just
# in case.  It is no longer handled before 'make install' is run as was
# the case in previous revisions of this HOWTO.
#
# If you can't remove all installed ImageMagick files before installing
# the new version below, running "locate [Mm]agick" and
# "lsof /usr/local/lib*/libMagick*" may help to find what is old and
# removable.

# Prerequisites:
# pkg-config
# XFree86 or X.org (optional)
# zlib
# bzip2
# graphviz
# libfpx
# lcms
# libpng
# libjpeg
# JasPer
# freetype
# libtiff
# JBIG-KIT
# libxml
# libwmf
# ghostscript - I use this one
# Netscape (optional)
# teTeX or TeX Live
# xterm (included as part of X)
# transfig's fig2dev
# netpbm
# lpr or cups
# compress/uncompress
# The Gimp
# groff
# sane's scanimage
# enscript
# wget
# gzip
# Perl
# libexif
# ...and lots more, most of which are optional (including X).  For details
# about other prereqs, see the MAGICK DELEGATES section of the README.txt file


# ImageMagick 7.x
# ===============
# 6.x is below

# Get it
cd
test -f installed/ImageMagick-7.0.8-12.tar.xz &&
 mv installed/ImageMagick-7.0.8-12.tar.xz .
test ! -f ImageMagick-7.0.8-12.tar.xz &&
 wget http://www.imagemagick.org/download/ImageMagick-7.0.8-12.tar.xz

# Verify tarball w/ sha1sum:
# (this came from my gpg-verified tarball)
echo "5d2b654c18d7d8253c234716de2b0653c221f9b6  ImageMagick-7.0.8-12\
.tar.xz" | sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 8277377A > /dev/null 2>&1 || gpg --recv-keys 8277377A ) &&
 wget -nc http://www.imagemagick.org/download/\
ImageMagick-7.0.8-12.tar.xz.asc &&
  gpg --verify ImageMagick-7.0.8-12.tar.xz.asc &&
   rm ImageMagick-7.0.8-12.tar.xz.asc

# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "ImageMagick-*" -exec rm -r {} \;
tar xJvf ~/ImageMagick-7.0.8-12.tar.xz
cd ImageMagick-7.0.8-12
test $UID = 0 && chown -R root:root .

# If you don't have libfpx installed, leave off --with-fpx below

## If you have a Windows partition mounted under Linux or have M$ core fonts
## installed, you can tell ImageMagick to use them by passing the path to
## configure like so:
# --with-windows-font-dir=/mnt/win/windows/fonts
# --with-windows-font-dir=/usr/share/fonts/msttcorefonts

# Configure the build
test -d /usr/local/lib64 &&
 ./configure --enable-static=no --libdir=/usr/local/lib64 \
  --mandir=/usr/local/man --with-fpx \
  --with-windows-font-dir=/usr/share/fonts/msttcorefonts
test ! -d /usr/local/lib64 &&
 ./configure --enable-static=no --mandir=/usr/local/man --with-fpx \
  --with-windows-font-dir=/usr/share/fonts/msttcorefonts

# Build it
make

# Become root to install it
su

# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg imagick imagemagick

# If you use Slackware and have an older version installed that was not
# configured with --with-mandir=/usr/local/man, you may have man page files
# in /usr/local/share/man/man1 also.  ...and unless you updated MANDIR
# in /etc/profile.d/man.sh, 'man' won't know they're there.
# If your /usr/local/share/man is a symlink to /usr/local/man, then you're
# OK.  If not, remove them.  For the list of files, run this from the
# source directory:
# find -type f -name "*.1" -exec basename {} \;

# Install it
make install
ldconfig

# Fix ownership and permissions of files created as root so your
# non-root account can remove them later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/ImageMagick-*.tar.*
mv ImageMagick-7.0.8-12.tar.xz installed/


# ImageMagick 6.x
# ===============
# 7.x is above

# If you're able, probably a good idea to clean up files from old versions
# of ImageMagick before installing a new one.  Skip down to the bottom
# then return here.  If you can't do that, running "locate [Mm]agick" and
# "lsof /usr/local/lib*/libMagick*" may help to find what is old and
# removable.

# Get it
cd
test -f installed/ImageMagick-6.9.10-23.tar.xz &&
 mv installed/ImageMagick-6.9.10-23.tar.xz .
test ! -f ImageMagick-6.9.10-23.tar.xz &&
 wget https://imagemagick.org/download/ImageMagick-6.9.10-23.tar.xz

# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "6c7e2c25e0b1c39ec42024d04cbdb2abc94806aaa24a0e7d9103ad347e4c11\
f8  ImageMagick-6.9.10-23.tar.xz" | sha256sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 8277377A > /dev/null 2>&1 || gpg --recv-keys 8277377A ) &&
 wget -nc https://imagemagick.org/download/\
ImageMagick-6.9.10-23.tar.xz.asc &&
  gpg --verify ImageMagick-6.9.10-23.tar.xz.asc &&
   rm ImageMagick-6.9.10-23.tar.xz.asc

# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "ImageMagick-*" -exec rm -r {} \;
tar xJvf ~/ImageMagick-6.9.10-23.tar.xz
cd ImageMagick-6.9.10-23
test $UID = 0 && chown -R root:root .

# If you don't have libfpx installed, leave off --with-fpx below

## If you have a Windows partition mounted under Linux or have M$ core fonts
## installed, you can tell ImageMagick to use them by passing the path to
## configure like so:
# --with-windows-font-dir=/mnt/win/windows/fonts
# --with-windows-font-dir=/usr/share/fonts/msttcorefonts

# Configure the build
test -d /usr/local/lib64 &&
 ./configure --enable-static=no --libdir=/usr/local/lib64 \
  --mandir=/usr/local/man --with-fpx \
  --with-windows-font-dir=/usr/share/fonts/msttcorefonts
test ! -d /usr/local/lib64 &&
 ./configure --enable-static=no --mandir=/usr/local/man --with-fpx \
  --with-windows-font-dir=/usr/share/fonts/msttcorefonts

# Build it
make

# Become root to install it
su

# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg imagick imagemagick

# If you use Slackware and have an older version installed that was not
# configured with --with-mandir=/usr/local/man, you may have man page files
# in /usr/local/share/man/man1 also.  ...and unless you updated MANDIR
# in /etc/profile.d/man.sh, 'man' won't know they're there.
# If your /usr/local/share/man is a symlink to /usr/local/man, then you're
# OK.  If not, remove them.  For the list of files, run this from the
# source directory:
# find -type f -name "*.1" -exec basename {} \;

# Install it
make install
ldconfig

# Fix ownership and permissions of files created as root so your
# non-root account can remove them later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/ImageMagick-*.tar.*
mv ImageMagick-6.9.10-23.tar.xz installed/


# If you ever want to uninstall ImageMagick, this should do it:
# (just keep in mind things compiled to use it may break)
cd
su
test -d src/ImageMagick-* && ( cd src/ImageMagick-* ; make uninstall )
for dir in doc etc include share;
do
  for num in 6 7;
  do
    test -d /usr/local/${dir}/ImageMagick-${num} &&
     rm -r /usr/local/${dir}/ImageMagick-${num}
  done
done
for libdir in lib lib64;
do
  test -d /usr/local/${libdir} &&
   find /usr/local/${libdir} -maxdepth 1 -type d -name "ImageMagick-*" \
    -exec rm -r {} \;
  test -d /usr/local/${libdir}/pkgconfig &&
   ( cd /usr/local/${libdir}/pkgconfig
     rm -f ImageMagick-*.pc ImageMagick++.pc ImageMagick++-*.pc )
done
( cd /usr/local/include
  rm -f Magick++.h Magick
  test -d Magick++ && rm -r Magick++ )
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "ImageMagick-*" -exec rm -r {} \;
rm -f ~/installed/ImageMagick-*.tar.*

Back to the list


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