Welcome Guest, Not a member yet? Register   Sign In
Creating 2 thumb images
#1

[eluser]EEssam[/eluser]
Hi guys,

I need to create 2 thumb images (different sizes). The following code is just creating the first one:

Code:
$config['image_library'] = 'gd2';
        $config['source_image'] = './system/application/images/65-1.jpg';
        $config['new_image'] = './system/application/images/65-thumb.jpg';
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 120;
        $config['height'] = 120;

        $this->load->library('image_lib', $config);

        $this->image_lib->resize();

        $this->image_lib->clear();

        $config['image_library'] = 'gd2';
        $config['source_image'] = './system/application/images/65-1.jpg';
        $config['new_image'] = './system/application/images/65-tiny.jpg';
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 48;
        $config['height'] = 48;

        $this->load->library('image_lib', $config);

        $this->image_lib->resize();
When I remove the first one code the second is being created normally!

Please help.
#2

[eluser]gon[/eluser]
This is from the user guide:

$this->image_lib->clear()

The clear function resets all of the values used when processing an image. You will want to call this if you are processing images in a loop.
#3

[eluser]EEssam[/eluser]
Hi,

As you can see from my code above, the function was called but it still not working.
#4

[eluser]EEssam[/eluser]
The good guy here had the same problem and posted the solution:

http://ellislab.com/forums/viewthread/91549/
#5

[eluser]gon[/eluser]
Sorry for not reading in detail...
#6

[eluser]Bramme[/eluser]
Indeed, you shouldn't be loading a library multiple times, that's why lots of them have the initialize function Wink
#7

[eluser]Colin Williams[/eluser]
Yeah, CI uses lazy instantiation, so your second call to $this->load->library() does nothing because the class is already instantiated.




Theme © iAndrew 2016 - Forum software by © MyBB