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:
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/libor-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
Optional Packages
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 installmust 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
configureandmaketo 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.