Welcome Guest, Not a member yet? Register   Sign In
Image Lib not creating Thumbs
#1

[eluser]Ki[/eluser]
Not sure why, but image library alwasy gives the most problems from all CI libs.
I am trying to do the following:
Upload file->rename watermark resize->create thumb

Code:
//UPLOAD AND RESIZE THE FILE
        $config = array();
        $config['source_image'] = $uploaded_data['full_path'];
        $config['new_image'] = $target;
        $config['width'] = 700;
        $config['height'] = 700;
        $config['quality'] = 80;
        $config['maintain_ratio'] = TRUE;
        $config['create_thumb'] = FALSE;
        
        $this->CI->load->library('image_lib',$config);
        $this->CI->image_lib->resize();
        $this->CI->image_lib->clear();

        // create thumb
        $config['source_image'] = $target;
        $config['new_image'] = $this->config['upload_path'].'sml_'.$file_name.'.jpg';
        $config['create_thumb'] = TRUE;
        $config['width'] = 75;
        $config['height'] = 50;

        $this->CI->image_lib->initialize($config);
        $this->CI->image_lib->resize();
        $this->CI->image_lib->clear();

        //add watermark
        $config=array();
        $config['source_image'] = $target;
        $config['wm_text'] = 'Copyright 2006 - John Doe';
        $config['wm_type'] = 'text';
        $config['wm_overlay_path'] = './logo/overlay.gif';
        $config['wm_type'] = 'overlay';
        $config['wm_vrt_alignment'] = 'top';
        $config['wm_hor_alignment'] = 'right';
        $config['dynamic_output'] = FALSE;
        $config['create_thumb'] = FALSE;

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

It creates the resized version but does not add watermark.

An a remark: Does anybody else find the $config['create_thumb'] useless? After all, it requires to specify width and height, so what is the point if same can be acomplished with resize? Is there any way I can resize uploaded image, watermark and create thumb in one shot?
#2

[eluser]pickupman[/eluser]
The wm_overlay_path variable should be full path to image. create_thumb is useful when you don't need to resize the original, but create a thumbnail of the original, and provides a common suffix appended to the first part of the filename string.
#3

[eluser]vitoco[/eluser]
if it doesn't work...maybe you shold use a conditional statement like it says in the manual, to catch the error.

A good practice is use the processing function conditionally, showing an error upon failure, like this:
Code:
if ( ! $this->image_lib->resize())
{
    echo $this->image_lib->display_errors();
}
Note: You can optionally specify the HTML formatting to be applied to the errors, by submitting the opening/closing tags in the function, like this:

Code:
$this->image_lib->display_errors('<p>', '</p>');

Saludos




Theme © iAndrew 2016 - Forum software by © MyBB