Saturday, March 5, 2011

ImageMagick Advanced Unix Installation

It's possible you don't want to concern yourself with advanced installation under Unix 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 Unix or Linux systems, lets begin.

Download & Unpack

ImageMagick builds on a variety of Unix and Unix-like operating systems including Linux, Solaris, FreeBSD, Mac OS X, and others. A compiler is required and fortunately almost all modern Unix systems have one. Download ImageMagick.tar.gz from ftp.imagemagick.org or its mirrors and verify the distribution against its message digest.
Unpack the distribution it with this command:

$magick> tar xvfz ImageMagick.tar.gz

Now that you have the ImageMagick Unix/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:

$magick> cd ImageMagick-6.6.8-0 
$magick> ./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 -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 -rpath to 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.