CodeIgniter Forums

Full Version: image_lib doesn't work nor produce any errors!?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


I'm trying to resize an image after an upload, but the script seems to terminate and return nothing on '$this->image_lib->resize()'.

Here's the code:
// upload file
if(!$this->upload->do_upload('image')) // if upload fails, process errors
            $file_upload_errors = array('error' => $this->upload->display_errors());
            return $file_upload_errors;
            // if it succeeds, get the upload data
            $file = array('upload_data' => $this->upload->data());
            // if file exceeds size restrictions
            if($file['upload_data']['image_width'] > 500 || $file['upload_data']['image_height'] > 500)
                // configure image library
                $settings['source_image'] = './uploads/' . $file['upload_data']['file_name'];;
                $settings['maintain_ratio'] = TRUE;
                $settings['width'] = 500
                $settings['height'] = 500

                // load and initialize image library
                $this->load->library('image_lib', $settings);
                // resize image
                if ( !$this->image_lib->resize())
                     // if resize fails, return errors
                     $file_upload_error = $this->image_lib->display_errors();
                     return $file_upload_error;
            // return uploaded file data
            return $file;

Do you have any idea why this won't work? the code works just fine without the resize bit.

Your help is much appreciated

El Forum

i got the same problem... Sad

El Forum

i got it..
check your $setting['source_image']. the system dont find the image, but wont declare any warnings.. ( about '@' stuff)
as an illustration to describe it, put my code on yours just right after it initiates.