如何在Bitnami的wamp-stack PHP v7.1.4上安装和使用ImageMagick / Imagick

如何在Bitnami的wamp-stack PHP v7.1.4上安装和使用ImageMagick / Imagick

问题描述:

I'm so confused on how to install/enable the use of Imagick on Bitnami's WAMP Stack... I look into php.ini and I see NOTHING about ImageMagick even though there's literally a folder dedicated to ImageMagick called imagemagick :o

When trying to do stuff in my web app, I get this error:

An uncaught Exception was encountered

Type: Error

Message: Class 'imagick' not found

This is my code:

    // Initialize new ImageMagick object
    $im = new imagick($dir_path.'/'.$original_img_filename);

    // Convert to PNG
    $im->setImageFormat('png');

    // Write image onto server
    $im->writeImage($filename.'.png');
    $im->clear();
    $im->destroy();

    // Delete original downloaded image file
    $is_deleted = unlink($dir_path.'/'.$original_img_filename);

Can anyone from Bitnami with knowledge and expertise in Bitnami's WAMP stack please bring to light the solution? It's kind of ridiculous that Bitnami claims it supports ImageMagick for PHP 7.1 but just adds a folder with ImageMagick in the name but with no actual explanation on how to enable it. I've spent countless hours on this. I have all the correct .dll files and added them as extensions in the php.ini file, restarted WAMP and still nothing.

Did it with an absolute file path, local file path, with and without quotes as well as with the back and forward slashes, and tested with and without quotes... EVERY SINGLE POSSIBILITY. I'm not sure exactly why it isn't showing up when I echo out phpinfo().

Thanks.

edit: Figured it out. I had to add SYSTEM VARIABLES.

Had to add a variable named: MAGICK_HOME with the value pointing to the root directory of ImageMagick.

And had to add the same directory to the PATH (and moved it up so that it is above the php one. But im not sure if that is needed. just did it in case.)

Figured it out AFTER HOURS OF FRUSTRATION AND BREAKS. Sorry.

Anyways I had to add SYSTEM VARIABLES (in addition to adding the dll extension in php.ini).

Had to add a variable named: MAGICK_HOME with the value pointing to the root directory of ImageMagick.

And had to add the same directory to the PATH (and moved it up so that it is above the php one. But im not sure if that is needed. just did it in case.)

You need to install ImageMagick first. Please download ImageMagick from https://www.imagemagick.org/script/binary-releases.php according to your OS.

Then edit php.ini and add new line (replace your installation path)

extension="C:\Bitnami\wampstack-5.6.6-0\php\ext\php_imagick.dll"

Restart WAMP and its done.