User Contributed Notes 14 notes

I struggled to get imagick installed for mamp and dug high and low. Iwas left with the impression that so many struggle with opensource and this type of install that it is almost a right of passage. For my part, I managed to find two threads that helped me and the steps work. A lot of people talked about macports and pear installs which are fine(I tried them), but 1) they sometimes don't get the latest version of what you need and 2) I can't tell what they're doing and where they're doing it.

It's much easier to me to download the stuff where i want it and be sure of what i got!

First of all download a tar image of the ImageMagick install from here:sourceforge.net/projects/imagemagick/files/

Unpack it and then from terminal issue the following commands in quotes:1. "cd ImageMagick-6.5.7" - go where you placed the folder

2. "./configure"

3. "make"

If ImageMagick configured and compiled without complaint, you are ready to install it on your system. Administrator privileges are required to install. To install, type the following command in terminal:

1. "sudo make install"

To check your ImageMagick installation enter the following command in terminal:

1. "make check"

Remember all commands are entered into terminal in the directory in which you unzipped your downloaded ImageMagick tar file. (the latest version of which at this time of writing is ImageMagick-6.5.7.)

Next we need to install Imagick.so which is what we want for PHP.

First of all we need to get the right file and we can get that from here:

pecl.php.net/package/imagick/download

At current writing the latest stable version is imagick-2.3.0.

Unpack the tar file and then enter the commands in quotes in terminal:

1. "cd imagick-2.2.3" - go where you placed the folder

2. "phpize"

3. "./configure --with-imagick=/opt/local"

4. "make"

5. "make install"

If you look at the bottom of the output, it will tell you where it has placed the imagick.so module. For me it was placed in:

/imagick-2.3.0/modules

which is where i had unpacked the downloaded imagick-2.3.0 file.

Then copy it into your MAMP PHP extensions folder.

For me it was: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/

Then, for PHP to honor the the extension, add the following line to the extensions section of your php.ini file:

extension=imagick.so

You should now have a working imagick extension with all of the resources for php found here:php.net/manual/en/book.imagick.php

There is a big disclaimer that should be made to all those about to venture on ImageMagick programming using PHP: the great, vast majority of WAMP (Windows-Apache-MySQL-PHP) servers do not support ImageMagick commands at all, since it is a "different package," and there appears to be no way to install ImageMagick through standard Add/Remove Applications within Linux (as far as standard Debian linux releases go). It's very easy to get Apache/PHP running in either Windows or Linux with pretty much any standard OS/distro supported so that you can run all of your own code on your own computer. But that's definitely not the case when you want Imagick to cooperate with your Apache server and your PHP code!

It took me almost an entire week just to get Apache/PHP/ImageMagick working all together nice and happily so that I could run my own PHP code on my own machine (natively, too). So, I decided to simply write down the steps, to help anyone else out who could need help.

Guide to Building an Apache/PHP/Imagick Server with Linux/CentOS 6.4:::

1. Install CentOS 6.4. (Theoretically, other versions of CentOS should work as well, but I simply chose the most recent one.) Also, you can very easily emulate CentOS within Windows (for instance, the unfree choice of VMWare).
2. Install PHP, PHP-Common, PHP-extensions, etc., from standard Application Package Manager ("Add/Remove Programs", usually in system tools somewhere). (You don't have to worry about Apache, because that comes with CentOS 6.4 anyway.)
3. Open up a terminal and enter admin mode with the command "su". You'll need a password for this.
4. Enter this command: yum install ImageMagick ImageMagick-devel
5. Enter this command: pecl install imagick
6. Modify php.ini and include the line "extension=imagick.so". This file is located at "/etc/php.ini" normally. The line must be exactly inserted in the section of "Dynamic Extensions", which begins with this commented out text:

Use the "search" feature of gedit to find the text. Add the extension below the commented out note in this section so that the result looks like:

--------------------------------
;;;;
; Note: packaged extension modules are now loaded via the .ini files
; found in the directory /etc/php.d; these are loaded by default.
;;;;

extension=imagick.so
--------------------------------

Putting the extension directly at the top caused me serious permission issues in running Imagick code. Also, with CentOS, the permissions automatically disable user control for this php.ini. Enter the following terminal command: "chown [YOUR-USERNAME] -R /etc/php.ini", without the quotes to get control to modify it. Note to insert your username where it states "[YOUR-USERNAME]".
7. Enter this command: "service httpd restart", without quotes, from admin mode. This restarts Apache/PHP/PHP's extensios now that you've installed ImageMagick. If this gives you an error, just try "service httpd start".

My favorite part about this method is that you can update your system with issuing the "yum update" command and then the "yum upgrade" command -- and the Apache/PHP/Imagick combo will still be working perfectly! Unlike some other guides out there for this, you don't need to rely on antiquated, unsupported versions that can be nearly impossible to find. Also, you don't need to worry about the MySQL, Hash, MBString, Exif packages, because they all seem to be installed and properly cooperating with PHP automatically after installing PHP from the Application Manager. This solution makes everything work well together.

The root directory of your public files is located at /var/www/html/. Normally, this folder is not owned by the user, so you'll get a permission error when trying to add files or folders to it. Correct that with entering admin mode in the terminal/command-line window ("su" command) and entering the following command: "chown [YOUR-USERNAME] -R /var/www/html/", without quotes. Again, replace "[YOUR-USERNAME]" with your actual user name. (Warning: The first time I did this, I was lazy and entered the command for only the "/var/" folder, which prevented my system ever from booting. It would always freeze with the notorious and googleable erro-message: "Could not update ICEauthority file /var/lib/gdm/.ICEauthority". So, make sure to change ownership only for "/var/www/html/".)

To view your root directory files as compiled, resultant, PHP pages, open up a browser and enter "127.0.0.1" as the address. So, a file in your root directory would be accessed at the following URL in your browser: http://127.0.0.1/your.file.php . If you get a "could not connect" error message, try the command "service httpd start" at the terminal window from admin mode. (You have to start this service manually every time the machine boots, although there's plenty of ways to automate it.)

I hope this helps! I tried a hundred different guides on getting Apache/PHP/Imagick to work together and none of them worked. Don't give up! ImageMagick is a package of really neat imaging functions!

checking ImageMagick MagickWand API configuration program... found in /usr/bin/Wand-configchecking if ImageMagick version is at least 6.2.4... configure: error: no. You need at least Imagemagick version 6.2.4 to use Imagick.ERROR: `/tmp/pear/temp/imagick/configure --with-imagick' failed

Installation of Imagick on Windows:-------------------------------------------

Here an important hint for all who want to use Imagick:

First of all: Forget this PECL.It is for Linux only.

In the old discussion boards I read that some years ago there was a DLL for PHP available on the FTP server of imagemagick.org. Once upon a time there has also been a CHM installation help file on FTP which also has been removed. The only thing you find today on the FTP server is a ridiculous text file:ftp://ftp.imagemagick.org/pub/ImageMagick/php/windows/README.txtThis file contains 3 links:2 links of them are dead meanwhile.The only working one is this:www.dirk.sh/dirk/magickwanda page of a chinese guy who offers a MagickWand.dll for PHP of 4 MB size (Q8, static compiled)But he discontinoued support since 2007.There is no installation manual available.

He only writes:"Please ref watson's post about how to install on Windows:redux.imagemagick.org/discourse-server/viewtopic.php?t=4708"

This page which uses stupid style sheet settings like "font-size:11%" which make parts of the text unreadable also was no help.

At the end all manuals say the same:Copy the DLL into the "ext" folder and add the entry to the php.ini:extension=dllnamerestart the Apache and you are done.

But this is not true: it simply does NOT work on Xampp.In a DOS box entering PHP.exe -i > Info.txtprints all installed modules.You also find:

But after executing phpinfo() MagickWand does NOT appear under the installed extensions. Strange!!And the Wand commands do NOT function like:$resource = NewMagickWand();

I also found a php_imagick.dll of 65 kB size in the internet which also does not work. It does not even appear in PHP -i.

There is no error in the Apache logfile!

I read all I could find in the internet and wasted 2 entire days, without success, now I'm sick of Imagick and I absolutely cannot understand why the guys of imagemagick.org don't offer a ready compiled dll with an installation manual anymore?

In general the Imagick page seems not very trustworthy:On the download page they do never explain what is the difference between the several versions. What doess static mean?They never explain. (Static means that the convert.exe does not depend on so many dlls. It only requires one external DLL, for that it has a size of 5 MB instead of 200 kb) And the explanation about the difference between Q8 and Q16 version is wrong: Q8 does NOT mean 8 Bits per pixel as the download page says. It means 8 Bit per color = 24 Bit per Pixel)

And I found an ugly misdesign:If you install the Q8 version on your local PC and want to copy the files from your harddisk to the server, then convert.exe will crash!Convert.exe depends on a Registry Entry. And if this is missing (on a server where you have not full access) it will crash. The strangest thing is that this registry key can contain any nonsense, it only must exist! How stupid!

So if you want to execute as an alternative the commandline tools like convert.exe from your PHP code you must add this Registry entries to the server:HKEY_LOCAL_MACHINE\SOFTWARE\ImageMagick\6.5.1\Q:8\ConfigurePathThe value can be anything.

But with the commandline tools you cannot obtain the width and height of an image in your PHP code. This is not possible.

I could not install via PECL or compiling from source because of an error from line 3339 of the configure file generated by phpize so I looked at the configure file at line 3339 and it was just a check for the PHP version using the php-config command with the --vernum switch which was not supported by my PHP version so I commented out that check from the configure file and then it would configure, compile, and install.

After installation, it put the shared object file in my php extension modules directory so I added an entry to my /etc/php.d directory to load the extension file and restarted apache and the imagick section is present in my info.php output.

PECL install imagick contantly fails due to the server is behind some firewall, so one may try 'phpize' way to install.

However, someone like me who doesn't want to use default options may experience thru failure situation. And if you google thru the cloud, you may find many people tell you to rpm imagick-devel with yum or apt. That does solve the problem.

However, In my case, my server already has php 5.3.1 installed under /usr/lcal/php & the linux doesn't have yum or apt service. Furthermore, I just installed imagemagick yesterday (Also quite a battle =.=) under /usr/local/imk

(note: You may see that I don't like default options, I like to install each package under different dir under /usr/local).

Today, I want to install imagick, so this is what I do:

1> add /usr/local/php/bin & /usr/local/imk/bin to path.

2> download imagick source of intended version (I use 3.0.b1).

3> enter that dir & issue 'phpize'.

(note:I got a habit to issue './configure --help > oo' & 'view oo' to see all the options first before installation)