1

在此处输入图像描述

我试图在 GD2 图像压缩库的帮助下压缩 codeigniter 中的图像大小,但它向我显示错误

Your server must support the GD image library in order to determine the image properties.

Your server does not support the GD function required to process this type of image.

但在我的服务器上显示 GD 已启用

array(12) { ["GD Version"]=> string(26) "bundled (2.1.0 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["WebP Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }

这是我的代码

$file_path = './public/order_images/';
        if($_FILES['image_name']['name']!="")
        {
            $config['upload_path']          = $file_path;
            $config['allowed_types']        = 'gif|jpg|png';
            // $config['max_size']             = 1000000;
            // print_r($config);exit;
            $this->load->library('upload', $config);
            $this->upload->initialize($config);
            if (!$this->upload->do_upload('image_name'))
            {
                $error = array('error' => $this->upload->display_errors());
                // print_r($error);exit;
            }
            else
            {

                $data = array('upload_data' => $this->upload->data());
                $zfile = $data['upload_data']['full_path']; // get file path
                chmod($zfile,0777); // CHMOD file

                $img_config['image_library']          = 'gd2';
                $img_config['source_image']          = $data['upload_data']['full_path'];
                $img_config['create_thumb']        = FALSE;
                $img_config['maintain_ratio']             = TRUE;
                $img_config['quality']             = '60%';
                $img_config['width']             = 150;
                $img_config['height']             = 75;
                $img_config['new_image']             = $_SERVER['DOCUMENT_ROOT'].'/public/order_new_img/new_'.$data['upload_data']['file_name'];
                // $this->resize($file_path,$data['upload_data']['file_name']);
                $size = filesize($data['upload_data']['full_path']);
                // pre($img_config);
                var_dump(gd_info());

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

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

                // $this->image_lib->resize();

                // pre(getimagesize($data['upload_data']['full_path']));
                if (!$this->image_lib->resize()){

                        echo $this->image_lib->display_errors();exit;

                    } else {

                        echo "done";exit;

                    }
                $this->image_lib->clear();
            }

            $image_name = $data['upload_data']['file_name'];
        }

我还检查了 php.info,因为它也显示 GD 已启用,但是当我点击提交按钮时,此错误显示

GD 不支持

请帮我找到解决方案

谢谢进阶

4

0 回答 0