CodeIgniter Forums
Can't Resize Two Images In Method (Using Image Library) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Can't Resize Two Images In Method (Using Image Library) (/showthread.php?tid=35707)



Can't Resize Two Images In Method (Using Image Library) - El Forum - 11-08-2010

[eluser]mdvaldosta[/eluser]
Here's my code, where'd I go wrong? It creates the thumb, but leaves the original intact rather than resizing it also.
Code:
function _resize_image($filename)
    {
        // Load library
        $this->load->library('image_lib');
        
        // Make thumb configuration
        $config['image_library'] = 'gd2';
        $config['source_image'] = './assets/uploads/' . $filename;
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 200;
        $config['height'] = 150;

        // Make thumb from original image
        $this->image_lib->initialize($config);
        $this->image_lib->resize();

        // Clear the image library
        $this->image_lib->clear();
        
        // Resize original configuration
        $this->image_lib->clear();
        $config['image_library'] = 'gd2';
        $config['source_image'] = './assets/uploads/' . $filename;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 500;
        $config['height'] = 375;

        // Resize the original image
        $this->image_lib->initialize($config);
        $this->image_lib->resize();        
    }



Can't Resize Two Images In Method (Using Image Library) - El Forum - 11-09-2010

[eluser]Unknown[/eluser]
Hi Summer Student,

You've to unset the config.

unset($config);

Greetz,

I had the proplem two, and just clearing the libary doesn't work.

Greetz


Can't Resize Two Images In Method (Using Image Library) - El Forum - 11-09-2010

[eluser]mdvaldosta[/eluser]
That didn't work, but I got it using this:
Code:
// Make thumb configuration
        $config['image_library'] = 'gd2';
        $config['source_image'] = './assets/uploads/' . $filename;
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 200;
        $config['height'] = 150;

        // Make thumb from original image
        $this->load->library('image_lib', $config);
        $this->image_lib->resize();
        
        // Resize original configuration
        $config['image_library'] = 'gd2';
        $config['source_image'] = './assets/uploads/' . $filename;
        $config['create_thumb'] = FALSE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 500;
        $config['height'] = 370;

        // Resize the original image
        $this->image_lib->initialize($config);
        $this->image_lib->resize();