[eluser]-sek[/eluser]
I am confused by the image library as well. This evening I have not had much luck using the image library to upload a file and generate multiple resized versions from it.
I need to let the user upload an image of their choosing, which must be resized to a maximum dimension and then saved with a new name (either the image must be renamed or a copy created with the new name and the old file deleted) that fits a naming pattern.
* The uploaded file must be resized to our maximum dimensions and renamed according to our specific pattern: picture-[userid]-o.jpg for the "original" and a second image created at 48px wide named picture-[userid]-i.jpg for a square icon image.
I do not necessarily want to use the built in thumbnail since I cannot use the naming I want and apparently cannot create more than one image. Here is the code I'm using...it works if I comment one of the images out.
Code:
$img = $this->upload->data();
$id = $this->db_session->userdata('id');
$config['new_image'] = $img['file_path'] .'picture-profile-'. $id .'-i'. $img['file_ext'];
$config['image_library'] = 'gd2';
$config['source_image'] = $img['full_path'];
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 48;
$config['height'] = 48;
$this->load->library('image_lib', $config);
if ( ! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
$this->image_lib->clear();
$config['new_image'] = $img['file_path'] .'picture-profile-'. $id .'-o'. $img['file_ext'];
$config['image_library'] = 'gd2';
$config['source_image'] = $img['full_path'];
$config['create_thumb'] = FALSE;
//$config['thumb_marker'] = 't';
$config['maintain_ratio'] = TRUE;
$config['width'] = 320;
$config['height'] = 200;
$this->load->library('image_lib', $config);
if ( ! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
Sorry, it's getting late and I may be a little incoherent...