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

I did an image upload, changed the size many times in CI. The same code works on one page, but does not work on another page. when I show an error, he says: "Your server does not support the GD function needed to process this type of image." Code for loading the image ... \

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 happening, I can’t understand .. ??

+8
codeigniter
source share
3 answers

change your first lines:

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

in

 $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); 
+4
source share

During my project, I had a similar problem. This link will help me solve it.

Replace

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

from

 $this->load->library('image_lib'); // Set your config up $this->image_lib->initialize($config); // Do your manipulation $this->image_lib->clear(); 
+11
source share

If nothing works (in my case), the error may be the whole problem.

  • Check if gd is installed, on linux you would do

    Installed list sudo yum | grep php

  • If it is not installed, install it.

    sudo yum install php-gd-package-name

  • RESTART your apache

    sudo service httpd restart

-one
source share

All Articles