简体   繁体   English

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

[英]How to install and use ImageMagick/Imagick on Bitnami's wamp-stack PHP v7.1.4

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我对如何在 Bitnami 的 WAMP 堆栈上安装/启用 Imagick 的使用感到非常困惑......我查看了 php.ini 并且我没有看到关于 ImageMagick 的任何内容,即使实际上有一个专门用于 ImageMagick 的文件夹称为imagemagick :o

When trying to do stuff in my web app, I get this error:尝试在我的 Web 应用程序中执行操作时,出现此错误:

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?任何来自 Bitnami 的在 Bitnami 的 WAMP 堆栈方面具有知识和专业知识的人都可以提出解决方案吗? 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. Bitnami 声称它支持 PHP 7.1 的 ImageMagick,但只是在名称中添加了一个带有 ImageMagick 的文件夹,但没有实际解释如何启用它,这有点荒谬。 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.我拥有所有正确的 .dll 文件并将它们添加为 php.ini 文件中的扩展名,重新启动 WAMP,但仍然没有。

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().我不确定为什么当我回显 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.必须添加一个名为: MAGICK_HOME的变量,其值指向 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.)并且必须将相同的目录添加到 PATH (并将其向上移动,使其位于 php 之上。但我不确定是否需要这样做。以防万一。)

You need to install ImageMagick first.您需要先安装 ImageMagick。 Please download ImageMagick from Link according to your OS.请根据您的操作系统从链接下载 ImageMagick。

Then edit php.ini and add new line (replace your installation path)然后编辑php.ini并添加新行(替换您的安装路径)

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

Restart WAMP and its done.重新启动 WAMP 并完成。

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).无论如何,我不得不添加系统变量(除了在 php.ini 中添加 dll 扩展名)。

Had to add a variable named: MAGICK_HOME with the value pointing to the root directory of ImageMagick.必须添加一个名为: MAGICK_HOME的变量,其值指向 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.)并且必须将相同的目录添加到 PATH (并将其向上移动,使其位于 php 之上。但我不确定是否需要这样做。以防万一。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM