ImageMagick and imagick php module on shared hosting


 * Note: Here are Instructions for Using Dreamhost's pre-installed ImageMagick with MediaWiki One-Click Installs on Dreamhost: Image Magick

=How to install and configure ImageMagick and imagick php module/extension on shared hosting=

If you are also interested in GraphicsMagick / gmagick, nearly the same process is described here: GraphicsMagick and gmagick php module on shared hosting

Both extensions could be active at the same time, if the tips described in the above link are followed !

Prerequisites

 * ssh account activated
 * PHP 5.3 used

Steps

 * Prepare the environment
 * Install ImageMagick
 * Build imagick php extension
 * Configure PHP to use this extension
 * Edit the Local Settings File on your Wiki

Prepare the environment
$ mkdir build $ mkdir local
 * Login with ssh to your account, all the operation described below will be done in this ssh connection.
 * Create a "build" directory where all the required tools will be downloaded, configured and then compiled
 * Create a "local" directory where all the required tools will be deployed

Install ImageMagick
$ cd build $ wget "ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz" $ tar zxvf ImageMagick.tar.gz
 * Download ImageMagick

In my case the downloaded version was ImageMagick-6.7.9-8, adapt the following command to your downloaded version ... $ cd ImageMagick-6.7.9-8 $ ./configure --prefix=$HOME/local --with-gslib --with-gs-font-dir=/usr/share/fonts/type1/gsfonts/ --without-perl $ make $ make install
 * Configure and make ImageMagick

If everything ran smoothly, up-to-date ImageMagick binaries, libs collection, documentation etc are available in your "local" directory (and sub-directory)

$ export PATH=$HOME/local/bin:$PATH
 * Now you start using this "local" directory ...

Build imagick PHP module
$ cd $HOME/build

Visit http://pecl.php.net/package/imagick and choose the version you want to use ... In my case, I took the latest stable version : 3.0.1 ... Adapt the following commands with the choosen version : $ wget "http://pecl.php.net/get/imagick-3.0.1.tgz" $ tar zxvf imagick-3.0.1.tgz $ cd imagick-3.0.1

Now we need some tricks to make imagick compilation more smooth ... $ phpize $ export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig $ ln -s $HOME/local/include/ImageMagick-6 $HOME/local/include/ImageMagick $ ./configure --prefix=$HOME/local --with-imagick=$HOME/local --with-php-config=/usr/local/php53/bin/php-config $ make

Several compilation warnings, don't be afraid .. The important thing is:

Libraries have been installed in: /home/ /build/imagick-3.0.1/modules

Configure PHP to use this extension
If you don't already have a .php/5.3 directory, create it. Then:

$ cd $HOME/.php/5.3 $ mkdir extensions $ cp $HOME/build/imagick-3.0.1/modules/imagick.so extensions $ echo "extension = $HOME/.php/5.3/extensions/imagick.so" >> phprc

Edit the Local Settings File on your Wiki
Try using this replacement code (as of February 14, 2014) if you hand load ImageMagick into a binary subdirectory

$wgEnableUploads = true; $wgUseImageMagick = true; $wgSVGConverterPath = "/usr/local/bin"
 * 1) To enable image uploads, make sure the
 * 2) 'images' 'images/thumbs' 'images/temp' and 'images/archive' directories
 * 3) are writable, then set these to true:
 * 1) Now add this additional code for Dreamhost

Replace { /usr ] with your user name on Dreamhost

For reasons I cannot explain, sometimes the example above does not work. It depends where you installed the code. Try various combinations of:

$wgImageMagickConvertCommand = "/usr/bin/convert"; or $wgImageMagickConvertCommand = "/usr/local/bin/convert";

$wgSVGConverterPath = "/usr/bin"; or $wgSVGConverterPath = "/usr/local/bin";

=An Older Set of Instructions=

If you need ImageMagick features that are not found in the installed version (as of this writing yerba has version 6.3.0) compiling and installing it from source is a snap.

This will install ImageMagick into $HOME/local/bin


 * 1) grab the source from http://imagemagick.org

~src$ wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
 * 2) untar imagemagick into a src directory

~src$ tar zxvf .tar.gz
 * 3) change to the imagemagick directory

~src$ cd ImageMagick
 * 4) configure and install

$ LDFLAGS="-L$HOME/local/lib -Wl,-rpath,$HOME/local/lib" $ LD_LIBRARY_PATH=$HOME/local/lib $ ./configure --prefix=$HOME/local --with-gslib --with-gs-font-dir=/usr/share/fonts/type1/gsfonts/ \ --with-perl-options=PREFIX=$HOME/perl $ make $ make install

In the case of '/usr/bin/ld: cannot find -lltdl' error try the previous version (would be great if anybody offer more reliable solution) ~src$ wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.7.9-10.tar.gz and repeat all procedure again

RMagick Note: If you're only compiling for RMagick, you can skip the  option and use   instead. You'll speed up the install and save on disk space.

GhostScript Note: currently (july 2008) GhostScript distribution on DreamHost servers is pretty old. If you intend to use ImageMagick's PDF features (eg. to convert content to images) you are encouraged to compile a newer version by yourself. You'll then have to set your shell PATH accordily to let ImageMagick's configure see your installation instead of the default one. Using an old GhostScript version can lead to problems with some PDF.

Other advanced options can be found at http://imagemagick.org/script/advanced-unix-installation.php.

Estimated Time
On zim, the  operation took about 2-3 minutes to complete during mid-day, whereas the   operation took about 30 minutes to execute.

On phaeton, compiling for RMagick (skipping Perl and Magick++ options),  took 2-3 minutes while   took roughly 15. Aupajo 01:57, 6 July 2008 (UTC)

More at ImageMagick.org

At Dreamhost ImageMagick command-line utilities are found under /usr/bin/.

DESCRIPTION ImageMagick provides a suite of command-line utilities for creating, converting, editing, and displaying images:

display is  a  machine architecture independent image processing and display facility. It can display an image on any workstation display running an X server.

import reads an image from any visible window on an X server and outputs it as an image file. You can  capture a single window, the entire screen, or any rectangular portion of the screen.

montage creates a composite by combining several separate images. The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile.

convert converts an input file using one image format to an output file with the same or differing  image  format while applying an arbitrary number of image transformations.

mogrify transforms an image or a sequence of images. These transforms include image scaling, image rotation, color reduction, and others. The transmogrified image overwrites the original image.

identify describes the format and characteristics of one or more image files. It will also report if an image is incomplete or corrupt.

composite composites images (blends or merges images together) to create new images.

compare compare an image to a reconstructed image.

conjure interprets and executes scripts in the Magick Scripting Language (MSL).

PHP Example
This example uses PHP to create a thumbnail and display it. The original file is called glass.jpg and the thumbnail is called glass.png and is then displayed in the browser at 150 pixels wide. This PHP script must be in the same directory as your image. To use a different name, enter it after $name. $extfrm is the extention of the file that is being read and $extto is the extension of the file being created. The period that is required between filename and extension can be placed either in $name or both extension strings. Also, $convert and $output shows two different ways to combine strings. $command is where you can change the commands that convert excepts. Silkrooster 18:33, 25 Feb 2006 (PST)

";   ?>