Welcome Guest, Not a member yet? Register   Sign In
Problem geting image resize to work

Most likely an obvious solution but I can't see it. I'm uploading an image file to a folder, resizing it and then writing the image path to a dB.

The original image upload works and the image path gets inserted in the dB but the image resize doesn't happen.

Hope some can help me see the what I'm not doing...code follows:

Uploading an image file as follows works fine:

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['overwrite'] = 'TRUE';
$this->load->library('upload', $config);

I then run a function to resize the image as follows:

$config['image_library'] = 'gd2';
$config['source_image'] = array('image' => 'uploads/' .element('file_name', $this->upload->data()));
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 250;
$config['height'] = 250;
$this->load->library('image_lib', $config);

And, finally I upload the image path to the dB:

$img_path = array('image' => 'uploads/' .element('file_name', $this->upload->data()));
$this->db->where('id', $id);
$this->db->update('personal', $img_path);

[eluser]Rick Jolly[/eluser]
Remove the first "$this->load->library(’image_lib’);" and it should work fine.

Many thanks...simple solution in deed. BTW, you also can pass an array for 'source_image'.

correction: I could not pass an array for 'source image'

Theme © iAndrew 2016 - Forum software by © MyBB