v7.1.2-35 Latest Stable Release

Advanced Linux Source Installation

Customize the configuration and installation of ImageMagick on Linux systems with advanced build options and troubleshooting guidance.

quickstart.sh
# Install via your favorite Package Manager
$ apt install imagemagick
# Convert PNG to WebP with compression
$ magick input.png -quality 85 output.webp
# Resize image maintaining aspect ratio
$ magick input.jpg -resize 800x600^ output.jpg

It's possible you don't want to concern yourself with advanced installation under Linux or Linux systems. If so, you also have the option of installing a pre-compiled binary release or if you still want to install from source without all the fuss see the simple Install From Source instructions. However, if you want to customize the configuration and installation of ImageMagick under Linux or Linux systems, let's begin.

Download & Unpack

ImageMagick builds on a variety of Linux and Linux-like operating systems including Linux, Solaris, FreeBSD, macOS, and others. A compiler is required and fortunately almost all modern Linux systems have one. Download ImageMagick-7.1.2-35.7z from GitHub .

Unpack the distribution with this command:

$ tar xvzf ImageMagick.tar.gz

Now that you have the ImageMagick Linux source distribution unpacked, let's configure it.

Configure

The configure script looks at your environment and decides what it can cobble together to get ImageMagick compiled and installed on your system. This includes finding a compiler, where your compiler header files are located (e.g., stdlib.h), and if any delegate libraries are available for ImageMagick to use (e.g., JPEG, PNG, TIFF, etc.). If you are willing to accept configure's default options, and build from within the source directory, you can simply type:

$ cd ImageMagick-7.1.2-35
./configure

Watch the configure script output to verify that it finds everything that you think it should. Pay particular attention to the last lines of the script output. For example, here is a recent report from our system:

configure output report sample
ImageMagick is configured as follows. Please verify that this configuration
matches your expectations.
Host system type: x86_64-unknown-linux-gnu
Build system type: x86_64-unknown-linux-gnu
                  Option                     Value
-------------------------------------------------------------------------------
Shared libraries  --enable-shared=yes		yes
Static libraries  --enable-static=yes		yes
Module support    --with-modules=yes		yes
GNU ld            --with-gnu-ld=yes		yes
Quantum depth     --with-quantum-depth=16	16
High Dynamic Range Imagery
                  --enable-hdri=no		no
Delegate Configuration:
BZLIB             --with-bzlib=yes		yes
Autotrace         --with-autotrace=yes	yes
DJVU              --with-djvu=yes		no
DPS               --with-dps=yes		no
FlashPIX          --with-fpx=yes		no
FontConfig        --with-fontconfig=yes	yes
FreeType          --with-freetype=yes		yes
GhostPCL          None			pcl6 (unknown)
GhostXPS          None			gxps (unknown)
Ghostscript       None			gs (8.63)
result_ghostscript_font_dir='none'
Ghostscript fonts --with-gs-font-dir=default
Ghostscript lib   --with-gslib=yes		no (failed tests)
Graphviz          --with-gvc=yes		yes
JBIG              --with-jbig=		no
JPEG v1           --with-jpeg=yes		yes
JPEG-2000         --with-jp2=yes		yes
LCMS              --with-lcms=yes		yes
LQR               --with-lqr=yes		no
Magick++          --with-magick-plus-plus=yes	yes
OpenEXR           --with-openexr=yes		yes
PERL              --with-perl=yes		/usr/bin/perl
PNG               --with-png=yes		yes
RSVG              --with-rsvg=yes		yes
TIFF              --with-tiff=yes		yes
result_windows_font_dir='none'
Windows fonts     --with-windows-font-dir=
WMF               --with-wmf=yes		yes
X11               --with-x=			yes
XML               --with-xml=yes		yes
ZLIB              --with-zlib=yes		yes
X11 Configuration:
      X_CFLAGS        =
      X_PRE_LIBS      = -lSM -lICE
      X_LIBS          =
      X_EXTRA_LIBS    =
Options used to compile and link:
  PREFIX          = /usr/local
  EXEC-PREFIX     = /usr/local
  VERSION         = 6.4.8
  CC              = gcc -std=gnu99
  CFLAGS          = -fopenmp -g -O2 -Wall -W -pthread
  MAGICK_CFLAGS   = -fopenmp -g -O2 -Wall -W -pthread
  CPPFLAGS        = -I/usr/local/include/ImageMagick
  PCFLAGS         = -fopenmp
  DEFS            = -DHAVE_CONFIG_H
  LDFLAGS         = -lfreetype
  MAGICK_LDFLAGS  = -L/usr/local/lib -lfreetype
  LIBS            = -lMagickCore-Q16 -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext
                    -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lpthread -lltdl
  CXX             = g++
  CXXFLAGS        = -g -O2 -Wall -W -pthread

You can influence the choice of compiler, compilation flags, or libraries of the configure script by setting initial values for variables in the configure command line. These include, among others:

CC
Name of C compiler (e.g. cc -Xa) to use.
CXX
Name of C++ compiler to use (e.g. CC).
CFLAGS
Compiler flags (e.g. -g -O2) to compile C code.
CXXFLAGS
Compiler flags (e.g. -g -O2) to compile C++ code.
CPPFLAGS
Include paths (e.g. -I/usr/local) to look for header files.
LDFLAGS
Library paths (e.g. -L/usr/local) to look for libraries. Systems that support the notion of a library run-path may require an additional argument in order to find shared libraries at run time (e.g., Solaris requires -R/path; some Linux systems work with -rpath /usr/local/lib or -Wl,-rpath,/usr/local/lib).
LIBS
Extra libraries (e.g. -l/usr/local/lib) required to link.

Here is an example of setting configure variables from the command line:

configure CC=c99 CFLAGS=-O2 LDFLAGS='-L/usr/local/lib -R/usr/local/lib' LIBS=-lposix

Any variable (e.g., CPPFLAGS or LDFLAGS) which requires a directory path must specify an absolute path rather than a relative path.

Configure can usually find the X include and library files automagically, but if it doesn't, you can use the --x-includes=path and --x-libraries=path options to specify their locations.

The configure script provides a number of ImageMagick specific options. When disabling an option, --disable-something is equivalent to specifying --enable-something=no and --without-something is equivalent to --with-something=no. The configure options are as follows (execute configure --help to see all options).

ImageMagick options represent either features to be enabled, disabled, or packages to be included in the build. When a feature is enabled (via --enable-something), it enables code already present in ImageMagick. When a package is enabled (via --with-something), the configure script will search for it, and if it is properly installed and ready to use (headers and built libraries are found by compiler) it will be included in the build. The configure script is delivered with all features disabled and all packages enabled. In general, the only reason to disable a package is if a package exists but it is unsuitable for the build (perhaps an old version or not compiled with the right compilation flags).

Optional Features

Feature Option Description
--enable-shared Build the shared libraries and support for loading coder and process modules. Shared libraries are preferred because they allow programs to share common code, making individual programs much smaller. In addition, shared libraries are required in order for PerlMagick to be dynamically loaded by an installed PERL (otherwise an additional PERL must be installed).

ImageMagick built with delegates can pose additional challenges. If built using static libraries (default without --enable-shared), delegate libraries may be built as static or shared. However, if built using shared libraries, all delegate libraries must also be built as shared libraries. Static libraries usually have extension .a, while shared libraries typically have extensions like .so, .sa, or .dll. Code in shared libraries normally must be compiled using a special compiler option to produce Position Independent Code (PIC) (e.g., -fPIC for gcc).

If --enable-shared is not specified, a new PERL interpreter (PerlMagick) is built statically linked against the PerlMagick extension. If specified, PerlMagick is built as a dynamically loadable object.
--disable-static Static archive libraries (with extension .a) are not built. If building shared libraries, there is little value to building static libraries (reasons to build static include: easier debugging, no external dependencies, inability to build shared libraries, etc.).
--disable-installed Disable building an installed ImageMagick (default enabled). By default the build is configured to formally install into a directory tree. Use this option so that ImageMagick doesn't use hard-coded paths and locates support files by computing an offset path from the executable or MAGICK_HOME environment variable.
--enable-ccmalloc Enable 'ccmalloc' memory debug support (default disabled).
--enable-prof Enable 'prof' profiling support (default disabled).
--enable-gprof Enable 'gprof' profiling support (default disabled).
--enable-gcov Enable 'gcov' profiling support (default disabled).
--disable-openmp Disable OpenMP (default enabled). Certain ImageMagick algorithms, like convolution, achieve significant speed-up with OpenMP on modern multi-core processors.
--disable-largefile Disable support for large (64 bit) file offsets. By default, ImageMagick compiles with support for large files (> 2GB on 32-bit CPU) if supported by the OS.

Optional Packages

Package Option Description
--with-quantum-depth Number of bits in a pixel quantum (default 16). Specify bits per pixel quantum (red, green, blue, alpha components). Supported arguments are 8, 16, or 32 (default 16 recommended).

Ranges:
Quantum Depth     Valid Range (Decimal)   Valid Range (Hex)
    8             0-255                   00-FF
   16             0-65535                 0000-FFFF
   32             0-4294967295            00000000-FFFFFFFF
Larger quantums require more memory and can run more slowly (e.g., 16-bit can be 15% to 50% slower and take twice as much memory as 8-bit). Virtual memory equation: (5 * Quantum Depth * Rows * Columns) / 8.
--enable-hdri Accurately represent the wide range of intensity levels.
--enable-osx-universal-binary Build a universal binary on OS X.
--without-modules Disable support for dynamically loadable modules. Coders and process modules are built as loadable modules under [prefix]/lib/ImageMagick-X.X.X/modules-QN.
--with-cache Set pixel cache threshold (defaults to available memory). Sets max heap memory before switching to memory-mapped temporary files.
--without-threads Disable threads support. By default, multi-thread support is enabled.
--with-frozenpaths Enable frozen delegate paths. Saves full paths to programs using locations determined by configure.
--without-magick-plus-plus Disable build/install of Magick++, the C++ API to ImageMagick.
--without-perl / --with-perl Disable or specify Perl binary for PerlMagick. By default PerlMagick is conveniently compiled and installed as part of the normal configure/make process.
--with-perl-options=OPTIONS Options to pass on command-line when generating PerlMagick's Makefile from Makefile.PL (e.g. PREFIX=/some/place).
--without-bzlib Disable BZLIB support.
--without-dps Disable Display PostScript support.
--with-fpx Enable FlashPIX support.
--without-freetype Disable TrueType support.
--with-gslib Enable Ghostscript library support.
--without-jbig Disable JBIG support.
--without-jpeg Disable JPEG support.
--without-jp2 Disable JPEG v2 support.
--without-lcms Disable LCMS support.
--without-lzma Disable LZMA support.
--without-png Disable PNG support.
--without-tiff Disable TIFF support.
--without-wmf Disable WMF support.
--with-fontpath Prepend to default font search path.
--with-gs-font-dir Directory containing Ghostscript Postscript Type 1 font files.
--with-windows-font-dir Directory containing MS-Windows fonts.
--without-xml Disable XML support.
--without-zlib Disable ZLIB support.
--without-x Don't use the X Window System. Disables display, animate, and import sub-commands.
--with-share-path=DIR Alternate path to share directory (default share/ImageMagick).
--with-libstdc=DIR Use libstdc++ in DIR (for GNU C++).

While configure is designed to ease installation of ImageMagick, it often discovers problems that would otherwise be encountered later when compiling. The configure script tests for headers and libraries by executing the compiler (CC) with specified flags. Errors are logged to config.log. Errors in config.log are normal because configure works by trying something and seeing if it fails (only a problem if a test should have passed on your system).

Common causes of configure failures: 1) a delegate header is not in header include path; 2) a delegate library is not in linker search/run path; 3) a delegate library is missing a function; or 4) compilation environment is faulty. If problems persist, report issues to the ImageMagick Defect Support Forum with OS details and config.log.

Build

Once ImageMagick is configured, these standard build targets are available from the generated make files:

make
Build ImageMagick.
sudo make install
Install ImageMagick.
make check
Run tests using installed ImageMagick (sudo make install must be done first). Ghostscript and Freetype are prerequisites for text and EPS/PS/PDF tests.
make clean
Remove everything in build directory created by make.
make distclean
Remove everything created by configure and make to start from scratch.
make uninstall
Remove all files installed by sudo make install.

In most cases you will simply want to compile ImageMagick with this command:

make

Install

Now that ImageMagick is configured and built, type:

make install

By default, binaries install in /usr/local/bin, libraries in /usr/local/lib, headers in /usr/local/include, and documentation in /usr/local/share. You can specify an alternative prefix via configure option --prefix=PATH.

To confirm your installation was successful, ensure the installation directory is in your executable path and type:

magick logo: logo.gif
identify logo.gif

To verify the build configuration and supported formats:

magick identify -list configure
magick identify -list format

Linux-specific Build Instructions

Download a source RPM from imagemagick.org or mirrors. Build with:

rpmbuild --rebuild ImageMagick.src.rpm

After the build, locate the RPMS folder and install the binary RPM distribution:

rpm -ivh ImageMagick-7.1.2.-?.*.rpm

macOS-specific Build Instructions

Perform these steps as an administrator or with the sudo command:

Install MacPorts and run:

sudo port -v install freetype +bytecode
sudo port -v install librsvg
sudo port -v install graphviz +gs +wmf +jbig +jpeg2 +lcms

Install latest Xcode from Apple. Download the ImageMagick source distribution and unpack:

tar xvzf ImageMagick-7.1.2-35.tar.gz
cd ImageMagick-7.1.2-35

Configure, build, and install ImageMagick:

./configure --prefix=/opt --with-quantum-depth=16 \
  --disable-dependency-tracking --with-x=yes \
  --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib/ \
  --without-perl
make
sudo make install

MinGW-specific Build Instructions

Download and install delegate libraries from GnuWin32 . Next type:

tar jxvf ImageMagick-7.1.2-35-?.tar.bz2
cd ImageMagick-7.1.2-35
export CPPFLAGS="-Ic:/Progra~1/GnuWin32/include"
export LDFLAGS="-Lc:/Progra~1/GnuWin32/lib"
./configure --without-perl
make
sudo make install

Dealing with Unexpected Problems

Chances are the download, configure, build, and install went flawlessly, however certain environments may cause issues. Here is corrective guidance:

Build Problems

If the build complains about missing dependencies (e.g., .deps/source.PLO), add --disable-dependency-tracking to your configure command line.

For unresolved link symbols, try adding LDFLAGS to configure:

configure LDFLAGS='-L/usr/local/lib -R/usr/local/lib'

Dynamic Linker Run-time Bindings

On some systems, ImageMagick may not find its shared library libMagick.so. Try running ldconfig:

/sbin/ldconfig /usr/local/lib

Delegate Libraries

Warnings like no decode/encode delegate for this image format indicate external libraries or headers were missing during build. Install the requisite library/headers and reconfigure/rebuild.

PerlMagick

If PerlMagick fails to link with libperl.a is not found, rerun configure with --enable-shared or --enable-shared --with-modules.