1

enter image description here

I am trying to compress the image size in codeigniter with the help of GD2 Image compression Library but its showing me error

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.

But on my server It is showing GD enabled

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) }

Here is my code

$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'];
        }

I also checked in php.info in that its also showing GD enabled but when I hit submit button this error showing

GD Not support

Please Help me to find the solution

Thank you in Advanced

iazizkhan
  • 322
  • 1
  • 5
  • 19
  • is anyone is there ? – iazizkhan Jul 04 '18 at 18:47
  • Not related to your problem, but you don't need the line `$this->upload->initialize($config);` because `initialize` ran when this call was made `$this->load->library('upload', $config);` – DFriend Jul 04 '18 at 19:58
  • The first error happens in `image_lib::initialize` when PHP returns false to `function_exists('getimagesize').` But that makes no sense because `phpinfo()` clearly shows GD is enabled. There are newer versions of GD available maybe upgrading the server to a newer version of GD will help. – DFriend Jul 04 '18 at 20:14
  • What I do know , Can you help me to solve this issue – iazizkhan Jul 05 '18 at 17:04

0 Answers0