CodeIgniter Forums
Help! GD Support enabled, CI tells me its not - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help! GD Support enabled, CI tells me its not (/showthread.php?tid=1894)



Help! GD Support enabled, CI tells me its not - El Forum - 07-03-2007

[eluser]herbageonion[/eluser]
Hi, I have GD Support enabled on my server but CI tells me:

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

Code From Controller:
Code:
$img_config['image_library']  = 'GD2';
$img_config['source_image']   = $file_data['full_path'];
$img_config['create_thumb']   = TRUE;
$img_config['maintain_ratio'] = TRUE;
$img_config['width']          = 100;
$img_config['height']         = 100;
                    
$this->load->library('image_lib', $img_config);
if ( ! $this->image_lib->resize() )
{
    echo $this->image_lib->display_errors();
}
else
{
    // Save
}

From phpinfo():
Code:
GD Support: enabled
GD Version: bundled (2.0.28 compatible)
FreeType Support: enabled
FreeType Linkage: with freetype
GIF Read Support: enabled
GIF Create Support: enabled
JPG Support: enabled
PNG Support: enabled
WBMP Support: enabled
XBM Support: enabled

Can anyone tell me what the problem is?

Cheers
- E


Help! GD Support enabled, CI tells me its not - El Forum - 07-03-2007

[eluser]ztinger[/eluser]
I had the same problem too.


In the constructor or at the begining of you function, load the library

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



then, within the code you posted, try reeplacing one line:




Code:
//$this->load->library('image_lib', $img_config);
// replace the above line with:
  $this -> image_lib -> initialize($img_config);

And tell me how it goes..


Help! GD Support enabled, CI tells me its not - El Forum - 07-03-2007

[eluser]herbageonion[/eluser]
Hey, thanks for replying. I tried that, no luck though. Still getting the same message. Really stumped with this one, I tried changing the 'image_library' back to 'GD' but no luck there either. Any other suggestions? I'm using PHP 4.3.1 by the way, would that have any bearing on it?


Help! GD Support enabled, CI tells me its not - El Forum - 07-03-2007

[eluser]ztinger[/eluser]
can you post your entire code?

I mean the constructor and then that particular function code.


Help! GD Support enabled, CI tells me its not - El Forum - 07-04-2007

[eluser]Crimp[/eluser]
The question is also what type of image you are feeding it. If you look through the CI library, you'll see eactly what GD functions are being used for your image type. Setting type/types allowed in configs may also have some impact on the outcome.


Help! GD Support enabled, CI tells me its not - El Forum - 07-04-2007

[eluser]herbageonion[/eluser]
Hi ztinger,

Here is the code from the Constructor and the Edit Method as requested, thanks for having a look.

Code:
class News extends Controller
{
    function News()
    {
        parent::Controller();

        // Load Helpers
        $this->load->helper( array('url', 'date', 'text', 'form') );
        // Load Libraries
        $this->load->library( array('session', 'validation', 'image_lib') );
        // Load Models
        $this->load->model('news_model');
        
        if ($this->session->userdata('logged_in') != true )
        {
            redirect('login', 'location');
        }
    }
        
    function edit()
    {
        // Set Id
        $id    = $this->uri->segment(3);
        $this->load->plugin('xinha');
        // Set up View Vars
        $data['title']        = $this->config->item('site_name') . " :: News & Information Items :: Edit";
        $data['heading']      = $this->config->item('site_name');
        $data['active']       = 'news';
        $data['css']          = 'news.css';
        $data['site_url']     = $this->config->item('base_url');
        $data['news_item']    = $this->news_model->get_news_item($id);
        $data['hidejquery']   = 'true';
        $data['xinha_js']     = javascript_xihna(array('news_extract', 'news_text'));
        // Check for sent form
        $form_was_sent        = $this->input->post('btn_edit_news');
        if (!$form_was_sent)
        {
            $this->load->view('news_edit', $data);
        }
        else
        {
            $rules['news_header']    = "trim|required|max_length[255]|xss_clean";
            $rules['userfile']       = "trim|xss_clean";
            $rules['news_date']      = "trim|required|xss_clean";
            $rules['news_extract']   = "trim|required|max_length[255]|xss_clean";
            $rules['news_text']      = "trim|required|xss_clean";

            $fields['news_header']   = 'Header';
            $fields['userfile']      = 'Image';
            $fields['news_date']     = 'Date';
            $fields['news_extract']  = 'Extract';
            $fields['news_text']     = 'Body';

            $this->validation->set_rules($rules);
            $this->validation->set_fields($fields);
            
            if ($this->validation->run() == FALSE)
            {
                $this->load->view('news_edit', $data);
            }
            else
            {
                // Upload an Image
                $file_config['upload_path']    = './uploads/';
                $file_config['allowed_types']  = 'gif|jpg|png';
                $file_config['max_size']       = '500';
                $file_config['max_width']      = '1024';
                $file_config['max_height']     = '768';
                
                $this->load->library('upload', $file_config);
                $file_data  = $this->upload->data();
                $header     = $this->input->post('news_header');
                $date       = $this->input->post('news_date');
                $extract    = $this->input->post('news_extract');
                $text       = $this->input->post('news_text');
                $image      = $file_data['file_name'];
                            
                if ( ! $this->upload->do_upload())
                {
                    die('<h2>Could not upload photo!</h2><p>'.$this->upload->display_errors().'</p>');
                    
                }    
                else
                {
                    // Resize the Image
                    $img_config['image_library']  = 'GD';
                    $img_config['source_image']   = $file_data['full_path'];
                    $img_config['create_thumb']   = TRUE;
                    $img_config['maintain_ratio'] = TRUE;
                    $img_config['width']          = 100;
                    $img_config['height']         = 100;
                    
                    $this->image_lib->initialize($img_config);

                    if ( ! $this->image_lib->resize())
                    {
                        echo $this->image_lib->display_errors();
                    }
                    else
                    {
                        $edit = $this->news_model->save_item($id, $header, $date, $extract, $text, $image);
                    }
                }
            }
        }
    }
}

Hi, Crimp, I'm uploading a jpg. I'll have a look through the libraries now I'll let ye know if I find anything to help.

Cheers


Help! GD Support enabled, CI tells me its not - El Forum - 07-04-2007

[eluser]ztinger[/eluser]
hmmm. have you tried with both 'GD' and 'GD2' ?


Help! GD Support enabled, CI tells me its not - El Forum - 07-05-2007

[eluser]herbageonion[/eluser]
Hey ztinger, yeah I tried both but still no luck. I really cant figure it out.


Help! GD Support enabled, CI tells me its not - El Forum - 07-05-2007

[eluser]modano[/eluser]
I have the same problem...Sad


Help! GD Support enabled, CI tells me its not - El Forum - 07-05-2007

[eluser]batteries[/eluser]
have you tried reinstalling GD?