Download & Unpack • Configure • Build • Install • Linux-specific Build Instructions • macOS-specific Build Instructions • MinGW-specific Build Instructions • Dealing with Unexpected Problems
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, lets 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-29.7z from GitHub.
Unpack the distribution it with this command:
$ tar xvzf ImageMagick.tar.gz
Now that you have the ImageMagick Linux/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-29 ./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:
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 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. For example, the Solaris linker requires an argument of the form -R/path. Some Linux systems will work with-rpath /usr/local/lib, while some other Linux systems who's gcc does not pass-rpathto the linker, require an argument of the form-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 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).
Here are the optional features you can configure:
Here are the optional packages you can configure:
While configure is designed to ease installation of ImageMagick, it often discovers problems that would otherwise be encountered later when compiling ImageMagick. The configure script tests for headers and libraries by executing the compiler (CC) with the specified compilation flags (CFLAGS), pre-processor flags (CPPFLAGS), and linker flags (LDFLAGS). Any errors are logged to the file config.log. If configure fails to discover a header or library please review this log file to determine why, however, please be aware that *errors in the config.log are normal* because configure works by trying something and seeing if it fails. An error in config.log is only a problem if the test should have passed on your system.
Common causes of configure failures are: 1) a delegate header is not in the header include path (CPPFLAGS -I option); 2) a delegate library is not in the linker search/run path (LDFLAGS -L/-R option); 3) a delegate library is missing a function (old version?); or 4) compilation environment is faulty.
If all reasonable corrective actions have been tried and the problem appears be due to a flaw in the configure script, please send a bug report to the ImageMagick Defect Support Forum. All bug reports should contain the operating system type (as reported by uname -a) and the compiler/compiler-version. A copy of the configure script output and/or the relevant portion of config.log file may be valuable in order to find the problem. If you post portions of config.log, please also send a script of the configure output and a description of what you expected to see (and why) so the failure you are observing can be identified and resolved.
ImageMagick is now configured and ready to build
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 the installed ImageMagick (
sudo make installmust be done first). Ghostscript and Freetype are prerequisites, otherwise certain unit tests that render text and the EPS, PS, and PDF formats will likely fail. These unit tests require the open security policy to pass. - make clean
- Remove everything in the build directory created by
make. - make distclean
- remove everything in the build directory created by
configureandmake. This useful if you want to start over from scratch. - make uninstall
- Remove all files from the system which are (or would be) installed by
sudo make installusing the current configuration. Note that this target is imperfect for PerlMagick since Perl no longer supports an uninstall target.
In most cases you will simply want to compile ImageMagick with this command:
make
Once built, you can optionally install ImageMagick on your system as discussed below.
Install
Now that ImageMagick is configured and built, type:
make install
to install it.
By default, ImageMagick is installs binaries in /../usr/local/bin, libraries in /../usr/local/lib, header files in /../usr/local/include and documentation in /../usr/local/share. You can specify an alternative installation prefix other than /../usr/local by giving configure the option --prefix=PATH. This valuable in case you don't have privileges to install under the default paths or if you want to install in the system directories instead.
To confirm your installation of the ImageMagick distribution was successful, ensure that the installation directory is in your executable search path and type:
magick logo: logo.gif
identify logo.gif
The ImageMagick logo is displayed on your X11 display.
To verify the ImageMagick build configuration, type:
$ magick identify -list configure
To list which image formats are supported , type:
$ magick identify -list format
For a more comprehensive test, you run the ImageMagick test suite by typing:
make check
Ghostscript is a prerequisite, otherwise the EPS, PS, and PDF tests will fail. Note that due to differences between the developer's environment and your own it is possible that a few tests may fail even though the results are ok. Differences between the developer's environment and your own may include the compiler, the CPU type, and the library versions used. The ImageMagick developers use the current release of all dependent libraries.
Linux-specific Build instructions
Download ImageMagick.src.rpm from imagemagick.org or its mirrors.
Build ImageMagick with this command:
rpmbuild --rebuild ImageMagick.src.rpm
After the build you, locate the RPMS folder and install the ImageMagick 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. Download and install MacPorts and type the following commands:
sudo port -v install freetype +bytecode
sudo port -v install librsvg
sudo port -v install graphviz +gs +wmf +jbig +jpeg2 +lcms
This installs many of the delegate libraries ImageMagick will utilize such as JPEG and FreeType.
Install the latest Xcode from Apple.
Use the port command to install any delegate libraries you require, for example:
sudo port install jpeg
Now lets build ImageMagick:
Download the ImageMagick source distribution and verify the distribution against its provenance .
Unpack and change into the top-level ImageMagick directory:
tar xvzf ImageMagick-7.1.2-29.tar.gz
cd ImageMagick-7.1.2-29
Configure 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"
Build ImageMagick:
make
Install ImageMagick:
sudo make install
To verify your install, type
/opt/local/bin/identify -list font
to list all the fonts ImageMagick knows about.
To test the ImageMagick GUI, in a new shell, type:
display -display :0
MinGW-specific Build instructions
Although you can download and install delegate libraries yourself, many are already available in the GnuWin32 distribution. Download and install whichever delegate libraries you require such as JPEG, PNG, TIFF, etc. Make sure you specify the development headers when you install a package. Next type,
tar jxvf ImageMagick-7.1.2-29-?.tar.bz2
cd ImageMagick-7.1.2-29
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 of ImageMagick went flawlessly as it is intended, however, certain systems and environments may cause one or more steps to fail. We discuss a few problems we've run across and how to take corrective action to ensure you have a working release of ImageMagick
Build Problems
If the build complains about missing dependencies (e.g. .deps/source.PLO), add --disable-dependency-tracking to your configure command line.
Some systems may fail to link at build time due to unresolved symbols. Try adding the LDFLAGS to the configure command line:
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 the ldconfig with the library path:
/sbin/ldconfig /usr/local/lib
Solaris and Linux systems have the ldd command which is useful to track which libraries ImageMagick depends on:
ldd `which convert`
Delegate Libraries
On occasion you may receive these warnings:
no decode delegate for this image format
no encode delegate for this image format
This exception indicates that an external delegate library or its headers were not available when ImageMagick was built. To add support for the image format, download and install the requisite delegate library and its header files and reconfigure, rebuild, and reinstall ImageMagick. As an example, lets add support for the JPEG image format. First we install the JPEG RPMS:
yum install libjpeg libjpeg-devel
Now reconfigure, rebuild, and reinstall ImageMagick. To verify JPEG is now properly supported within ImageMagick, use this command:
$ magick identify -list format
You should see a mode of rw- associated with the JPEG tag. This mode means the image can be read or written and can only support one image per image file.
PerlMagick
If PerlMagick fails to link with a message similar to libperl.a is not found, rerun configure with the --enable-shared or --enable-shared --with-modules options.