【问题标题】:Your server does not support the GD function required to process this type of image您的服务器不支持处理此类图像所需的 GD 功能
【发布时间】:2014-04-29 10:32:18
【问题描述】:

Your server does not support the GD function required to process this type of image. 正在砸我的头。我不明白哪一部分是错的!路径应该是准确的。

鉴于源图片是 resources/images/upload/BAACN_13853.jpeg

for($i=0; $i<count($result); $i++){
    if($result[$i]['condition'] == "Success"){
        //**************** RESIZE *******************/

            $config['image_library'] = 'GD2';
            $config['source_image'] = $result[$i]['msg'];
            $config['new_image'] = "/resources/images/upload_thumb/";
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            if($width != NULL || $width != 0){
                $config['width'] = $width;
            }
            if($width != NULL || $width != 0){
                $config['height'] = $height;
            }

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

            if($this->image_lib->resize()){
                echo $result[$i]['msg']." resized successfully.<br>";
            }else{
                echo $result[$i]['msg']." resized failed!!<br>";
            };
            $this->image_lib->clear();
    }else{

        echo $result[$i]['msg']."<br>";
    }
}

【问题讨论】:

  • 你有什么样的服务器操作系统?您可能需要安装 php-gd 模块
  • 我在 Windows 7 上使用 WAMP。如何安装它?
  • 对了,已经启用了。
  • 它究竟在哪一行抛出异常?在 $this->image_lib->resize() 上?请在此处添加 resize() 函数体。也请在此处发布 phpinfo() 输出。
  • 你也可以显示 HTML 吗?

标签: php codeigniter


【解决方案1】:

要解决此问题,请删除开头的 正斜杠,如下所示:

$config['source_image'] = $result[$i]['msg'];
$config['new_image'] = "/resources/images/upload_thumb/";

确保 $result[$i]['msg'] 不以 正斜杠

开头

【讨论】:

    【解决方案2】:

    可能是您多次加载 image_lib。不要多次加载 image_lib。在自动加载库中添加 image_lib 并更改

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

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-15
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    相关资源
    最近更新 更多