Linux HOWTOs

About | Home | Search

HOWTO: imagick
Description: PHP wrapper for ImageMagick
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

# PECL imagick
# ============
# PHP: ImageMagick - Manual
# PHP Imagick by Example

# In general you can just run 'pecl install imagick', or maybe this:
# C_INCLUDE_PATH=/usr/local/include/ImageMagick-6 pecl install imagick
# but if that is not good enough for you, see below for the latest source
# release and how to install it from the Git repository.

# I was unable to build 3.4.3 via pecl or released source using ImageMagick 7,
# but was able to build it with the code in Git

# I was able to build 3.4.4 with ImageMagick 6 via
# 'C_INCLUDE_PATH=/usr/local/include/ImageMagick-6 pecl install imagick'
# but got a symbol lookup error.
# It did work for me as below using 3.4.4 from source.

# imagick 3.4.4
# =============
# Prerequisites:
# ImageMagick

# Get it
test -f installed/imagick-3.4.4.tgz &&
 mv installed/imagick-3.4.4.tgz .
test ! -f imagick-3.4.4.tgz &&

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

# Make it configurable & buildable

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
 ./configure --with-imagick=/usr/local --with-libdir=lib64

# Configure the build for anything else:
test $(uname -m) != 'x86_64' &&
 ./configure --with-imagick=/usr/local

# Build it

# Install it
su -c "make install"

# Save the source for later
mkdir -p -m 0700 installed
rm -f installed/imagick-*.tgz
mv -f imagick-3.4.4.tgz installed/

# imagick from Git
# ================
# Prerequisites:
# ImageMagick
# Git

rm -f ~/installed/imagick-*.tgz
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "imagick-*" -exec rm -r {} \;

# If it's there already, clean it up and update it
test -d ./imagick &&
 ( cd imagick
   make distclean
   git fetch )

# If it's not there already, get it via 'git clone'
test ! -d ./imagick &&
 git clone

cd imagick

# Make it configurable and buildable

# Configure the build
test $(uname -m) = 'x86_64' && ./configure --with-libdir=lib64
test $(uname -m) != 'x86_64' && ./configure

# Build it

# Test the build
make test

# Install it
su -c "make install"

# This should get you a in somewhere like this:
# /usr/local/lib64/extensions/no-debug-non-zts-20170718

# Now start|restart Apache + PHP

# If there are any issues with it, to disable it, comment out the
# line in /usr/local/lib64/php.ini - or wherever yours is, it may be in
# /etc/httpd or any number of other places...
# If there are issues, you should see something like this in error_log
# PHP Warning:  PHP Startup: Unable to load dynamic library
# '/usr/local/lib64/extensions/no-debug-zts-20151012/'

Back to the list

Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>