Installing and Using ImageMagick with Imagick PHP Extension (php_imagick.dll) on WAMP

The php_imagick extension enables WAMP servers such as WampDeveloper Pro to create, edit, convert, and/or manipulate images via PHP using the ImageMagick software on Windows.

WampDeveloper Pro comes integrated with both the ImageMagick package and the Imagick PHP extension.

To enable the Imagick PHP Extension in WampDeveloper Pro:

1. Open file php.ini –
C:\WampDeveloper\Config\Php\php.ini

2. Near the end of php.ini, locate the ImageMagick section –

[ImageMagick]
;extension="C:\WampDeveloper\Components\Php\ext\php_imagick\php_imagick.dll"
;imagick.locale_fix=0
;imagick.progress_monitor=0

3. Uncomment the load line for this extension (remove the ‘;’ character from the beginning of the line) –

[ImageMagick]
extension="C:\WampDeveloper\Components\Php\ext\php_imagick\php_imagick.dll"

4. Save file. Restart Apache.

5. [optional] If not present already in your WAMP, download and extract PHP’s ImageMagick dependency files from http://windows.php.net/downloads/pecl/deps/, and into folder C:\WampDeveloper\Tools\ImageMagick\. Only extract the “\bin” files from the zip (and directly into the folder). This should match the environmental variable MAGICK_HOME=C:\WampDeveloper\Tools\ImageMagick set.

Afterwards, Imagick will be loaded by PHP and you can verify this via phpinfo.php…

imagick

5. Test imagick:

A. Create a scaled thumbnail image…

<?php

// if full path is not specified, will look for file in Apache's folder.

$im = new imagick('C:\WampDeveloper\Websites\www.example.com\webroot\imagick\pic.jpg');

// resize by 200 width and keep the ratio
$im->thumbnailImage(200, 0);

// if full path is not specified, file will end up in Apache's folder.

// write to disk
$im->writeImage('C:\WampDeveloper\Websites\www.example.com\webroot\imagick\pic_thumbnail.jpg');

echo 'Image Thumbnail Created.';

?>

B. Covert JGP image to PNG image format…

<?php

$image = 'C:\WampDeveloper\Websites\www.example.com\webroot\imagick\pic.jpg';

// a new imagick object
$im = new Imagick();

// ping the image
$im->pingImage($image);

// read the image into the object
$im->readImage($image);

// convert to png
$im->setImageFormat("png");

// write image to disk
$im->writeImage('C:\WampDeveloper\Websites\www.example.com\webroot\imagick\pic.png');

echo 'Image Converted.';

?>

One thought on “Installing and Using ImageMagick with Imagick PHP Extension (php_imagick.dll) on WAMP”

  1. PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\WampDeveloper\Components\Php\ext\php_imagick\php_imagick.dll’ – The specified procedure could not be found.

    If you see the above error message, it’s possible that a mismatched DLL is getting loaded, from some other version of ImageMagick or php_imagick that was previously installed on your system.

    1. Make sure that no Tools\ImageMagick files or php_imagick extension and DLL files have been replaced with other versions.

    2. Are there any outside (outside \WampDeveloper) ImageMagick files or DLLs present on the system from some other installation? Check for Imagemagick DLLs in the syswow64 folder.

    3. Check to make this Environmental Variable is set correctly (open command line, execute: set):
    MAGICK_HOME=C:\WampDeveloper\Tools\ImageMagick

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>