Welcome Guest, Not a member yet? Register   Sign In
Image multiple resize
#1

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

[eluser]Jason Hamilton-Mascioli[/eluser]
Add this line to your foreach loop

Code:
$this->image_lib->clear()
#3

[eluser]Kentish[/eluser]
I have added it but still same prob...
#4

[eluser]Otemu[/eluser]
Auto load the library, then use:

Code:
$this->image_lib->initialize($config);
instead of
Code:
$this->load->library('image_lib', $config);
#5

[eluser]Kentish[/eluser]
this one works, thanks to both Smile




Theme © iAndrew 2016 - Forum software by © MyBB