[eluser]Kentish[/eluser]
Hello
Am trying to get several sizes out of an image that i upload.
I have used tried the resize() function but its resizing the uploaded image only once. i.e using the first configurations only.
Here is the code :
Code:
public function resize_file($filename)
{
$configs = array();
$configs[] = array('source_image' => 'uploads/'.$filename,
'new_image' => 'uploads/thumbs/thumb/thumb.jpg',
'width' => 120, 'height' => 120);
$configs[] = array('source_image' => 'uploads/'.$filename,
'new_image' => 'uploads/thumbs/120x120/thumb.jpg',
'width' => 120, 'height' => 120, 'maintain_ratio' => FALSE);
$configs[] = array('source_image' => 'uploads/'.$filename,
'new_image' => 'uploads/thumbs/160x90/thumb.jpg',
'width' => 160, 'height' => 90, 'maintain_ratio' => FALSE);
$configs[] = array('source_image' =>'uploads/'.$filename,
'new_image' => 'uploads/thumbs/small/thumb.jpg',
'width' => 240, 'height' => 240);
$configs[] = array('source_image' => 'uploads/'.$filename,
'new_image' => 'uploads/thumbs/medium/thumb.jpg',
'width' => 800, 'height' => 800);
//Loop through the array to create thumbs
foreach ($configs as $config) {
$this->load->library('image_lib',$config);
$this->image_lib->resize();
}}