Welcome Guest, Not a member yet? Register   Sign In
Image manipulation bug
#1

[eluser]EugeneS[/eluser]
ok here is code i use:
Code:
$this->load->library('image_lib');

                // START Image resizing
                $config['source_image'] = $this->dir_to_upload.$this->file_name;
                $config['quality'] = '100%';
                $config['width'] = '80';
                $config['height'] = '80';
                $config['create_thumb'] = true;
                // END Image resizing
                $this->image_lib->initialize($config);

                $this->image_lib->resize();

                // START watermarking the image
                $config['source_image'] = $this->dir_to_upload.$this->file_name;
                $config['create_thumb'] = false;
                $config['wm_type'] = 'overlay';
                $config['wm_overlay_path'] = $this->dir_to_upload.'../watermark.gif';
                $config['wm_vrt_alignment'] = 'bottom';
                $config['wm_hor_alignment'] = 'right';
                // END watermarking the image

                $this->image_lib->initialize($config);

                $this->image_lib->watermark();


without $config['create_thumb'] = false; in the watermarking config it:
1) removes previously created thumb
2) it keep initial big image NOT watermarked
3) it creates fullsize image with the postfix _thumb and watermark it

it seems to me that Initialize method do not reset some internal variables inside the class after the previous operation.

PS: it doesnt matter if for watermarking i rename $config to $config_wm (i just expect this proposal from you guys Smile )


first my try was (and supposed to work correct but it doesnt)
Code:
$this->load->library('image_lib');

                // START Image resizing
                $config['source_image'] = $this->dir_to_upload.$this->file_name;
                $config['quality'] = '100%';
                $config['width'] = '80';
                $config['height'] = '80';
                $config['create_thumb'] = true;
                // END Image resizing

                // START watermarking the image
                $config['wm_type'] = 'overlay';
                $config['wm_overlay_path'] = $this->dir_to_upload.'../watermark.gif';
                $config['wm_vrt_alignment'] = 'bottom';
                $config['wm_hor_alignment'] = 'right';
                // END watermarking the image

                $this->image_lib->initialize($config);

                $this->image_lib->resize();

                $this->image_lib->watermark();
#2

[eluser]Unknown[/eluser]
I'm new to CI myself, but it looks like there is a function image_lib->clear() that you can use in between initializations to reset the config variables, so you do something like this:

Code:
$this->image_lib->initialize($config1);
$this->image_lib->resize();

// etc. etc. etc.

// now process the image in another way

$this->image_lib->clear(); // this resets all the config variables
$this->image_lib->initialize( $config2 ); // give a new set of parameters
$this->image_lib->resize();

----

That said, it looks to me like there's a bug in image_lib->clear() that does not clear out the set value of the CREATE_THUMB param...I just posted about that to the bugs forum.
#3

[eluser]EugeneS[/eluser]
might be, i havent found anything about Clear function in documentation and because i found how to solve the problem i didnt look through the class to find additional functions Smile
#4

[eluser]amosmos[/eluser]
the problem is that the clear function doesn't properly reset the 'create_thumb' option to FALSE...




Theme © iAndrew 2016 - Forum software by © MyBB