Welcome Guest, Not a member yet? Register   Sign In
how do I resize after I crop?
#1

[eluser]Unknown[/eluser]
So I'm cropping an image I'm uploading with the following code (successfully):

Code:
$file_name = $this->input->post('file_name');
        $x1 = $this->input->post('x1');
        $y1 = $this->input->post('y1');
        $x2 = $this->input->post('x2');
        $y2 = $this->input->post('y2');
        
        //die('width: '.$width.' height: '.$height.' id: '.$id.' file_name: '.$file_name.' x1: '.$x1.' x2: '.$x2.' y1: '.$y1.' y2: '.$y2.' w: '.$w.' h: '.$h);
        
        $config['image_library'] = 'gd2';
        $config['source_image']    = './images/uploads/temp/'.$file_name;
        $config['maintain_ratio'] = FALSE;
        $config['width'] = $y2;
        $config['height'] = $y2;
        $config['x_axis'] = $x1;
        $config['y_axis'] = $y1;
        $this->image_lib->initialize($config);

And at this point I want to resize the image as I have just gotten the selection and ratio I want and am not sure how to do this. Here's what I assumed would work immediately afterward in the same method:

Code:
$config['width'] = 180;
        $config['height'] = 180;
        $this->load->library('image_lib', $config);
        $this->image_lib->resize();
        
        if ( ! $this->image_lib->resize() )
        {
            die( $this->image_lib->display_errors() ); //
        }
It doesn't give any errors or anything, it just doesn't resize the image.

EDIT*
I figured out that I needed to $this->image_lib->clear(); after the crop and before the resize and it works. The crop is a little off, but I can fiddle with that. I would delete this post, but it says I can't.




Theme © iAndrew 2016 - Forum software by © MyBB