Monday, January 10, 2011

Install PHP ImageMagick and imagick on IIS 7.5

Install IIS 7.5 and PHP

Download and install ImageMagick.  Not all versions will work, at the time of writing the current version for windows was 6.6.7-0, however this version does not work, version 6.6.3-0 is the latest version that would work for me.  You can find version 6.6.3-0 at file://bpsnt04/transfer/Setups/ImageMagick/ImageMagick-6.6.3-0-Q8-windows-dll.exe.

You can find all windows version at this mirror http://image_magick.veidrodis.com/image_magick/binaries/

When installing the applications change the path to c:\ImageMagick.  Having spaces in the path seems to be a problem with PHP.
















Do not select any additional tasks from the "Select Additional Tasks" screen, the default is fine.

















To test the installation select Command Prompt from the Windows Start menu. Within the window type:
    convert logo: logo.miff
    imdisplay logo.miff
and the ImageMagick logo should be displayed in a window.


















Imagick is a PHP extension for ImageMagick.  The latest version of this file works fine and can be found at file://bpsnt04/transfer/Setups/ImageMagick/php_imagick.dll.

You can find the latest version at 
http://valokuva.org/builds/.  Be sure to download the x86 / VC9 / non-thread-safe version.

Download the file into the extensions folder for PHP, most likely c:\php\ext.  See the php,ini entry extension_dir for the location on your machine.

You must now configure PHP to know about the new extension.  Edit php.ini and add or uncomment the PHP_IMAGICK entry.

[PHP_IMAGICK]
extension=php_imagick.dll

Reboot the machine then check the phpinfo screen http://localhost/phpinfo.php.  There should now be an IMAGICK section.  Refer to the end of the blog How to host php on IIS 7.5 for help creating the phpinfo.php file.

























The user IUSR must be granted certain privledges. 
    C:\ImageMagick -> Read & execute, List folder contents and Read
    C:\Windows\Temp -> Modify, Read & execute, List folder contents, Read and Write

In addition, you may need to grant permissions to other folders used by PHP and ImageMagick

Some image formats require addional packages, PDF is one of those.  Since it is so common, we are going to install Ghostscript. The latest version at the time of writing works just fine, version 9.00, and be found at \\bpsnt04\transfer\Setups\ImageMagick\gs900w32.zip
All available files can be found at http://pages.cs.wisc.edu/~ghost/.


When installing the package accept all defaults.

6 comments:

  1. I get all the way down following your tutorial until i run my phpinfo.php page and the imagick section is not there.... any help?

    Windows Server 2008 x64 - IIS7 - PHP 5.3

    ReplyDelete
  2. Same problem as Benn - restarted web server and IIS admin, but no luck. Finally rebooted the whole machine and that did the trick!

    ReplyDelete
  3. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I will be subscribing to your feed and I hope you post again soon. Thanks!
    Classifieds php script

    ReplyDelete
  4. Thank you! Thank you!! Thank you!!! This worked. So many other posts on this problem did not work for me. Versions... Be sure to use the same version of imagemagick and imagick php wrapper. Otherwise it will fail silently. That is, PHP was throwing off no errors during initialization, but imagick simply would not load.

    The directory permissions was the final trick I needed, too.

    All this was just after seeing a very firm post from some one on another site, suggesting to give it up, under Windows, just use cmd / exec to access it. I was very depressed. Then I found you site. Thanks!

    ReplyDelete
  5. i got this error: php_imagick.dll' - %1 is not a valid Win32 application.

    ReplyDelete
  6. Awesome blog!!! It's so informative for you to get a software applications run faster on the Windows based PC.visit this link and free from all error of windows 7 problem.
    How To Remove Rundll Error
    Thanks
    Aalia lyon

    ReplyDelete