Welcome Guest, Not a member yet? Register   Sign In
Resizing more than one pic at once
#1

[eluser]Ci beginner[/eluser]
Hi there,

I got an issue with the image manipulator class of CodeIgniter. The first thumbnail is well-done:

Code:
function make_thumb_small($path)
    {
        $CI =& get_instance();
        $config['image_library'] = 'gd2';
        $config['source_image'] = $path;
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 75;
        $config['height'] = 50;
        $config['thumb_marker'] = '_thumb_small';
        $CI->load->library('image_lib', $config);
    }

And the second one looks as following:

Code:
function make_thumb_medium($path)
    {
        $CI =& get_instance();
        $config['image_library'] = 'gd2';
        $config['source_image'] = $path;
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 400;
        $config['height'] = 400;
        $config['thumb_marker'] = '_thumb_medium';
        $CI->load->library('image_lib', $config);
    }

But as you know, I can't upload the same lib twice. Or at least I think that is the issue. But I don't know how to bypass it. Could you give me some light with this?

Thank you!
#2

[eluser]wiredesignz[/eluser]
Try calling the image library initialize() method with the new $config array for the helper.
#3

[eluser]pistolPete[/eluser]
[quote author="wiredesignz" date="1250430567"]Try calling the image library initialize() method with the new $config array for the helper.[/quote]

And use the clear() function:

User guide:
Quote: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.

Code:
$this->image_lib->clear();
#4

[eluser]wiredesignz[/eluser]
Yes, Definitely use both methods to reset the image library between tasks. Thanks pistolPete Wink




Theme © iAndrew 2016 - Forum software by © MyBB