Welcome Guest, Not a member yet? Register   Sign In
"Your server does not support the GD function required to process this type of image"
#1

[eluser]inktri[/eluser]
I'm trying to create a thumbnail for every image uploaded. Unfortunately I keep on getting the error: "Your server does not support the GD function required to process this type of image", having tried both "$config['image_library'] = 'GD';" and "$config['image_library'] = 'GD2';".


Quote:gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled


Code:
function do_upload()
    {
        $config['upload_path'] = './photos/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '10240';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload()) {
            $error = array('error' => $this->upload->display_errors());
            
            $this->load->view('upload_form', $error);
        } else {
            $data = array('upload_data' => $this->upload->data());
            
            $d = $this->upload->data();
            
            $new_file_name = 'cow' . strtolower($d['file_ext']);
            rename($d['file_path'].$d['file_name'], $d['file_path'] . $new_file_name);
            
            $this->load->library('image_lib');
            $config['image_library'] = 'GD';
            $config['source_image'] = $d['file_path'] . $new_file_name;
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 75;
            $config['height'] = 50;
            $this->load->library('image_lib', $config);
            $this->image_lib->resize();
            
            echo $this->image_lib->display_errors();
            
            $this->load->view('upload_success', $data);
        }
    }


Anybody know what's wrong? Thanks for the help
#2

[eluser]vestrinang[/eluser]
Hello,
I just had the same error, not when uploading, but when trying to show a thumbnail (use of the resize() method in CI image_lib), and I also have GD2 installed. The error did not seem related to GD server library (as in your case), but on the fact that the image file was not where image_lib looked for it (I forgot to first upload the file...).
After I copied the file and set the read permissions, I also had a problem with the file copy which takes place inside the resize() method. When you don't specify a destination file name, the method should set the destination file name the same as the source file name, but from some reason it did not. So I added an additional check before the file is copied ( in the resize method of the image_lib class, i.e. image_process_gd() ):
Code:
if (($this->orig_width == $this->width AND $this->orig_height == $this->height) AND ($this->source_image != $this->new_image && $this->new_image != ''))
I added the last
Code:
&& $this->new_image != '')
(don't forget the opening brace).
And it worked for me, my thumbnail is displayed.
First, check if the tmp_file is copied to the upload destination in the upload process. Then, set the new file name the same as the source file name, or make the changes I did.
Hope this helps.
#3

[eluser]TheFuzzy0ne[/eluser]
It sounds to me like you may not have a supported image manipulation library installed on your server, because the image_lib doesn't seem to be initialising.

Are you both running something like XAMPP on your PCs?
#4

[eluser]vestrinang[/eluser]
Running on CentOS.
As I said above, my problem has been solved by (1)copying the file to its place(it happens..) and (2)adding an extra condition in the CI image_lib class.
#5

[eluser]TheFuzzy0ne[/eluser]
[quote author="vestrinang" date="1209243551"]Running on CentOS.
As I said above, my problem has been solved by (1)copying the file to its place(it happens..) and (2)adding an extra condition in the CI image_lib class.[/quote]

Yeah, sorry about that. I opened the reply box up in another tab earlier, replied, and never submitted it (freakin' kids... Wink )

I was about 4 hours too late, I think.
#6

[eluser]gunter[/eluser]
Code:
$this->load->library('image_lib');
            $config['image_library'] = 'GD';
            $config['source_image'] = $d['file_path'] . $new_file_name;
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 75;
            $config['height'] = 50;
            $this->load->library('image_lib', $config);

you are trying to load the library twice!
and so the config array will not be passed to the library - thats it.

so use this:
Code:
$this->load->library('image_lib')
$this->image_lib->initialize($config);

or simply delete the first $this->load->library('image_lib');
#7

[eluser]inktri[/eluser]
yea that was the bug haha. thanks gunter
#8

[eluser]gunter[/eluser]
you happy, I happy! :-)
(old indian saying)
#9

[eluser]TheFuzzy0ne[/eluser]
Wow, well spotted! I can't believe I missed that. I think I've got too much blood in my coffeestream.
#10

[eluser]gunter[/eluser]
if the image lib isn´t working, and path rights and everything is ok then it´s mostly because the people looping through $this->load->library('image_lib', $config);
I mentioned this today in the bug report, the user guide has to be changed, because the first example uses this...




Theme © iAndrew 2016 - Forum software by © MyBB