07-01-2008, 02:40 AM
[eluser]KeyStroke[/eluser]
Hi,
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:
Do you have any idea why this won't work? the code works just fine without the resize bit.
Your help is much appreciated
Hi,
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:
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;
}
else
{
// 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);
$this->image_lib->initialize($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