CodeIgniter Forums
Crop Image not working as expected - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Crop Image not working as expected (/showthread.php?tid=40804)



Crop Image not working as expected - El Forum - 04-19-2011

[eluser]imcl[/eluser]
I've posted this on SO to no avail, so here it goes.

I have this model to crop the user's image

Code:
function crop_avatar()
{
    $id = $this->tank_auth->get_user_id();

    //get current avatar
    $query = $this->db->get_where('user_profiles', array('id' => $id));
    foreach ($query->result() as $row) {
        $j[$row->avatar] = $row->avatar;
    }

    $config['image_library'] = 'gd';
    $config['source_image'] = '.' . substr("$row->avatar", 18);
    $config['x_axis'] = '10';
    $config['y_axis'] = '60';
    $this->load->library('image_lib');      
    $this->image_lib->initialize($config);

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

//      print_r($config);


}
which generates this array (via print_r)

Code:
Array
(
    [image_library] => gd
    [source_image] => ./images/avatars/b0b623057.jpg
    [x_axis] => 10
    [y_axis] => 60
)

For some reason unknown to me - there's no cropping going on. The original image passes straight thru this model, and is unchanged.

I do have GD on my server -- any ideas what might be wrong here?

Thanks!