Welcome Guest, Not a member yet? Register   Sign In
Crop output basic not working! please help!
#1

[eluser]morph london[/eluser]
I have been trying to solve this problem for ages now, if anyone could help it would be much apreciated. I am trying to crop an image but it just outputs nothing without an error. When i use resize instead of crop it works. But crop does nothing. Please help.

Code:
function output()
    {
        $folder = "assets/images/content/".$this->uri->segment(3)."/".$this->uri->segment(4)."/";
        
        $this->load->library('image_lib');
        
        // RESIZE
        $config['image_library'] = 'GD2';
        $config['source_image'] = $folder."main.jpg";
        $config['maintain_ratio'] = FALSE;
        $config['dynamic_output'] = TRUE;
        $config['x_axis'] = '100';
        $config['y_axis'] = '60';

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

        if (!$this->image_lib->crop())
        {
            echo $this->image_lib->display_errors();
        }
    }
#2

[eluser]tonanbarbarian[/eluser]
I have always found it is safest to use absolute links when working with the image library
so set you $folder to the absolute link rather than relative
Also try setting the dimensions as numbers not strings

i.e.
Code:
function output()
    {
        $folder = "/full/path/to/assets/images/content/".$this->uri->segment(3)."/".$this->uri->segment(4)."/";
        
        $this->load->library('image_lib');
        
        // RESIZE
        $config['image_library'] = 'GD2';
        $config['source_image'] = $folder."main.jpg";
        $config['maintain_ratio'] = FALSE;
        $config['dynamic_output'] = TRUE;
        $config['x_axis'] = 100;
        $config['y_axis'] = 60;

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

        if (!$this->image_lib->crop())
        {
            echo $this->image_lib->display_errors();
        }
    }




Theme © iAndrew 2016 - Forum software by © MyBB