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

[eluser]old_guy[/eluser]
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:

$this->load->library('image_lib');
$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);
$this->image_lib->resize();

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);
#2

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

[eluser]old_guy[/eluser]
Many thanks...simple solution in deed. BTW, you also can pass an array for 'source_image'.
#4

[eluser]old_guy[/eluser]
correction: I could not pass an array for 'source image'




Theme © iAndrew 2016 - Forum software by © MyBB