CodeIgniter Forums
Trouble with resizing image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Trouble with resizing image (/thread-7578.html)



Trouble with resizing image - El Forum - 04-15-2008

[eluser]jbads[/eluser]
When processing my image resize using the image manipulation class, I keep getting this error{

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

My php info files says GD is enabled and GD version is bundled (2.0.34 compatible)

Here is my processing code

Code:
//resize the image
            $this->load->library('image_lib');
            
            $config['image_library'] = 'GD';
            $config['source_image'] = '../imguploads/'.$user_id.'/avatar.'.$files['extension'];
            $config['width'] = 190;
            $config['master_dim'] = 'width';

            
            if(!$this->image_lib->resize())
            {
                $message = array('error_message' => $this->image_lib->display_errors());
                $this->session->set_userdata($message);
                redirect('profile/editprofile');
            
            }

Any help on this one would be awesome thanks.


Trouble with resizing image - El Forum - 04-15-2008

[eluser]Pascal Kriete[/eluser]
Try setting the image_library to GD2 instead of GD, and see if that works.


Trouble with resizing image - El Forum - 04-15-2008

[eluser]jbads[/eluser]
That didn't work, I still get the same error. Im running XAMPP on Windows if that gives anyone more clues?


Trouble with resizing image - El Forum - 06-17-2008

[eluser]recoilme[/eluser]
[quote author="jbads" date="1208318694"]That didn't work, I still get the same error. Im running XAMPP on Windows if that gives anyone more clues?[/quote]
i have same problem((


Trouble with resizing image - El Forum - 06-17-2008

[eluser]recoilme[/eluser]
inparo - right.
My problem was in gd2 and in wrong full path (for me). And wrong CI error reporting)
its work for me now:
Code:
function _upload_image($_FILES)
        {
            $this->load->library('upload');
            $this->load->library('image_lib');

            $config['upload_path'] = 'data/img/';
            $config['allowed_types'] = 'jpg|jpeg|gif|avi';
            $config['encrypt_name'] = 'TRUE';
            $this->upload->initialize($config);
            if ( ! $this->upload->do_upload()){
                $error = array('error' => $this->upload->display_errors());
                show_error($error);
            }
            $resarr = $this->upload->data();
            $file = $resarr['file_name'];

            if($file != '' and ($resarr['image_width']>780 or $resarr['image_height']>780) ){
                $config['image_library'] = 'GD2';
                $config['source_image'] = $resarr['full_path'];
                $config['maintain_ratio'] = TRUE;
                $config['width'] = 780;
                $config['height'] = 780;
                $config['master_dim'] = 'width';

                $this->image_lib->initialize($config);
                if ( ! $this->image_lib->resize()){
                    $error = array('error' => $this->image_lib->display_errors());
                    show_error($error);
                }
                $resarr['image_size_str'] = "width=\"780\"";
            }
            $upl = array();
            $upl = $resarr;
            return $upl;
        }