Welcome Guest, Not a member yet? Register   Sign In
Can't Resize Two Images In Method (Using Image Library)
#1

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

[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
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB