codeigniter 我已经安装了ImageMagick,但在图像库中仍然遇到错误

suzh9iv8  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(154)

我想使用imageMagick进行图像处理。现在我已经安装了imageMagick ImageMagick-6.8.4-10-Q16-x64-dll.exe,但仍然遇到以下错误:

Image processing failed. Please verify that your server supports the chosen protocol and that the path to your image library is correct.

我的密码是-

$config = array();
$config['image_library'] = 'ImageMagick';
$config['source_image'] = $file;
$config['new_image'] =  $file;
$config['library_path'] = '/usr/local/bin';
$config['create_thumb']    = FALSE;
$config['maintain_ratio'] = TRUE;
$config['width']     = 50;
$config['height']   = 50;
$this->image_lib->initialize($config); 
 if ( !$this->image_lib->resize())
        {
            echo "resize -".$this->image_lib->display_errors();
        } 
        $this->image_lib->clear();
cclgggtu

cclgggtu1#

等等。我假设你使用的是Windows(因为你安装了.exe),但是你的路径是Linux路径(/usr/local/bin)。仔细检查你的安装路径。

wbrvyc0a

wbrvyc0a2#

下面给了我预期的结果。希望你也能得到同样的结果。

$this->load->library('image_lib');

    //For resizing of image in size of dilog
    $config['image_library']  = 'ImageMagick';
    $config['library_path'] = 'C:\\ImageMagick\\';

    $config['source_image'] = $source_filepath;
    $config['new_image'] = $new_filepath;

    $config['width'] = 128;
    $config['height'] = 128;
    $config['quality'] = '100%';
    $config['maintain_ratio'] = TRUE;

    $this->image_lib->initialize($config);

    if (! $this->image_lib->resize()) {
        $error_msg = $this->image_lib->display_errors();
        print_r($error_msg);
    }
    else {
        echo "Done";
    }

这里

$config['library_path'] = 'C:\\ImageMagick\\';

是安装imageMagick应用程序的窗口路径。(尝试安装在这样一个文件夹中,我们可以很容易地找到它的路径)。将图像库更改为:

$config['image_library']  = 'ImageMagick';

&其他所有配置都保持不变。

相关问题