Linux HOWTOs

About | Home | Search


HOWTO: imagick
Description: PHP wrapper for ImageMagick
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 it via pecl or released source using ImageMagick 7,
# but was able to build it with the code in Git


# imagick 3.4.3
# =============
# Prerequisites:
# ImageMagick
# PHP

# Get it
cd
test -f installed/imagick-3.4.3.tgz &&
 mv installed/imagick-3.4.3.tgz .
test ! -f imagick-3.4.3.tgz &&
 wget https://pecl.php.net/get/imagick-3.4.3.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.3.tgz
cd imagick-3.4.3
test $UID = 0 && chown -R root:root .

# Make it configurable & buildable
phpize

# Configure the build
./configure --with-imagick=/usr/local

# Build it
make

# Install it
su -c "make install"

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


# imagick from Git
# ================
# Prerequisites:
# ImageMagick
# PHP
# 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 https://github.com/mkoppanen/imagick.git

cd imagick

# Make it configurable and buildable
phpize

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

# Build it
make

# Test the build
make test

# Install it
su -c "make install"

# This should get you a imagick.so in somewhere like this:
# /usr/local/lib64/extensions/no-debug-zts-20151012

# Now start|restart Apache + PHP

# If there are any issues with it, to disable it, comment out the imagick.so
# 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/imagick.so'

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>