Conrad Media
Conrad Media

Reputation: 87

Magic library does not run on wamp server

I am using magic library to change the resolution of the images. But I am getting following error when I am running the Wamp. enter image description here enter image description here

I am also sharing links of the website I have followed.

Upvotes: 0

Views: 260

Answers (1)

Kerry Kobashi
Kerry Kobashi

Reputation: 801

These are step by step instructions on how to get ImageMagick running under PHP in a Windows environment. Apache does not provide binaries for Windows and relies upon several sources to do so:

  • XAMPP
  • WampServer
  • Apache Lounge
  • Bitnami
  • Apache Haus

It is recommended to download either the XAMPP or WampServer distributions as they are complete packages that contain Apache HTTP server, PHP and MySql known and tested to work together.

Making ImageMagick work was not easy for me. It took two days of trial and error to get this to work. Hopefully this will help you get up and running faster. I have this running on the following:

  • Windows 7 Home Edition 64-bit
  • XAMPP 5.6.3
  • Apache HTTP 2.4.10 (Win32), VC 11
  • PHP 5.6.3 x86 VC 11, Thread safe

Thus, a 32-bit web framework compiled with VC 11 and thread safety enabled all running on 64-bit Windows 7. You must choose a 32-bit ImageMagick DLL distribution along with a 32-bit VC11 thread safe DLL wrapper to match.

The instructions below should work equally well with WampServer as there is no dependency on the Windows web framework.

The important thing to understand here is that you must know your web server environment and what components are installed and built with. you must match bitness, Visual C runtime, and thread safety configurations together.

Step #1: Install imageMagick to C:\ImageMagick

Go to Link and download the latest release. Use the 32 bit DLL version (ImageMagick-6.9.0.0-Q16-x86-dll.exe)

Install it into C:\ImageMagick directory

Step #2: Get the PHP wrapper from the Windows PECL repository

Go to http://pecl.php.net/package/imagick

Get the latest stable version, 3.1.2. You want the 32-bit, VC 11, thread safe version php_imagick-3.1.2-5.6-ts-vc11-x86.zip

Step #3: Create distribution directory

Create a /php/ext/imagemagick directory

Copy the ZIP into it and unzip it

Step #4: Make backup copy of DLLs

Make a C:\ImageMagick\Backup directory

Copy DLLs in the C:\ImageMagick directory to the C:\ImageMagick\Backup directory

Step #5: Overwrite DLLs

This is the most important step that if you don't do, will result in the PHP wrapper not loading correctly:

Take all the DLL files in \php\ext\ImageMagick and overwrite those in C:\ImageMagick

If you do a SET on the DOS command line you will see that the ImageMagick installer had created a entry into the system variable environment path (i.e. to C:\ImageMagick). Supporting DLLs will be picked up from there and they will be the Pecl Windows repository DLLs, not the distribution.

Step #6: Set module extension in PHP.INI

First, copy the php extension wrapper php_imagick.dll into the /php/ext directory. Then modify the PHP.INI to do this:

extension=php_imagick.dll

Step #7: Reboot Apache

Reboot Apache

Go to phpinfo and see that imagick is installed as a module.

Here's where you can learn more about your environment. Pay attention to stuff in phpinfo like:

  • Compiler: MSVC11 (Visual C++ 2012)
  • Architecture: x86 (32 bit; as opposed to x64 which is 64 bit)
  • Thread safety: enabled (TS)
  • Apache Environment Configuration (PATH should have C:\ImageMagick included)

More gory details: Installing ImageMagick with PHP and Windows

Upvotes: 1

Related Questions