Welcome Guest, Not a member yet? Register   Sign In
clear() function in Image Manipulation Class
#1

[eluser]verisof[/eluser]
Hi,

maybe you can explain this, but when I read "The clear function resets all of the values used when processing an image." in the user guide, I suppose that also width and height paramaters would be reseted.

For example, I upload an image, than resize it three times (there will be 3 copies in different sizes finally) and crop one of them. When resizing the last one, even though I use clear() function and pass configuration array without 'height' element in it to initialize() function, the height parameter has the value from the previous loop and it's resized incorrectly.

I solved it by adding one line of code to the definition of clear() fnction, so it looks like this now:

Code:
function clear()
{
        $props = array(
            'source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image',
            'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis',
            'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size',
            'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset',
            'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');

        // this line was added:
        $props = array_merge($props, array('width', 'height'));
        
        foreach ($props as $val)
        {
            $this->$val = '';
        }

        // special consideration for master_dim
        $this->master_dim = 'auto';
}

I haven't looked deeply if any other properties are skipped during clearing, so this is just for height and width.

Now I ask - was this (for some reason I would like to hear) skipped in clear() function intentionally? Or is this a bug in clear() function?




Theme © iAndrew 2016 - Forum software by © MyBB