Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

codeigniter

I had done image upload,resized many times in CI. The same code is working in one page but not working in other page . when i display the error it says" Your server does not support the GD function required to process this type of image." The code to upload image is ...\

 function do_upload() {

        $original_path = './uploads/activity_images/original';
        $resized_path = './uploads/activity_images/resized';
        $thumbs_path = './uploads/activity_images/thumb';
        $this->load->library('image_lib');

        $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png', //only accept these file types
            'max_size' => 2048, //2MB max
            'upload_path' => $original_path //upload directory    
        );
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        $image_data = $this->upload->data(); //upload the image
        $image1 = $image_data['file_name'];

        //your desired config for the resize() function
        $config = array(
            'source_image' => $image_data['full_path'], //path to the uploaded image
            'new_image' => $resized_path,
            'maintain_ratio' => true,
            'width' => 128,
            'height' => 128
        );
        $this->image_lib->initialize($config);
        $this->image_lib->resize();

        // for the Thumbnail image
        $config = array(
            'source_image' => $image_data['full_path'],
            'new_image' => $thumbs_path,
            'maintain_ratio' => true,
            'width' => 36,
            'height' => 36
        );
        //here is the second thumbnail, notice the call for the initialize() function again
        $this->image_lib->initialize($config);

        $this->image_lib->resize();
        //$this->image_lib->clear();
       echo  $this->image_lib->display_errors();
        var_dump(gd_info());
        die();
        return $image1;
    }

What is going on i can't understand..??

like image 302
Drudge Rajen Avatar asked Jun 04 '13 10:06

Drudge Rajen


3 Answers

During my project I faced similar problem. This link help me to solve it.

Replace

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

with

$this->load->library('image_lib');
// Set your config up
$this->image_lib->initialize($config);
// Do your manipulation
$this->image_lib->clear();
like image 146
mridul Avatar answered Nov 19 '22 01:11

mridul


change your first lines from:

$original_path = './uploads/activity_images/original';
$resized_path = './uploads/activity_images/resized';
$thumbs_path = './uploads/activity_images/thumb';
$this->load->library('image_lib');

to:

$config['image_library'] = 'gd2';
$original_path = './uploads/activity_images/original';
$resized_path = './uploads/activity_images/resized';
$thumbs_path = './uploads/activity_images/thumb';
$this->load->library('image_lib', $config);
like image 28
Kees Sonnema Avatar answered Nov 18 '22 23:11

Kees Sonnema


I had all of the above set still I was shown

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

I went through some research to re-installed or fixed the installation of the php-gd library. You can do this by issuing the following command:

sudo apt-get install php7.1-gd

and once done, I have restarted apache2

sudo service apache2 restart

It worked perfectly.

You can change php7.1-gd based on your PHP version installed on your machine.

like image 31
Dheeraj Thedijje Avatar answered Nov 19 '22 00:11

Dheeraj Thedijje