Welcome Guest, Not a member yet? Register   Sign In
Image Cropping Issues
#1

[eluser]dennismonsewicz[/eluser]
I have the following code in one of my controllers and it seems to resize the image but doesn't crop it. And the resizing is the wrong dimensions from what I set in my code

Code:
$config = array();
            $config['image_library'] = 'gd2';
            $config['source_image'] = $data['json']->{'file_path'};
            $config['maintain_ratio'] = TRUE;
            //$config['new_image'] = getcwd() . '/images/gallery/cropped_' . $data['json']->{'file_path'};
            $config['width'] = 277;
            $config['height'] = 104;
            $config['x_axis'] = 0;
            $config['y_axis'] = 20;
            $this->image_lib->clear();
            $this->image_lib->initialize($config);
            if(!$this->image_lib->crop()) {
                echo $this->image_lib->display_errors();
            }
            unset($config);

I am getting no errors so I have no idea why this isn't working.

Thanks in advanced!
#2

[eluser]treeface[/eluser]
Can you try commenting out the width and height config lines? I ask because of this:

<i>All preferences listed in the table above are available for [the crop] function except these: rotation_angle, width, height, create_thumb, new_image.</i>
#3

[eluser]dennismonsewicz[/eluser]
ok that worked... but is there anyway to specify a width and height of the cropping area? I need like a cropped strip of each image uploaded.. Almost creating a thumbnail, if that makes sense
#4

[eluser]mr_madness[/eluser]
I have that same problem... i know in the user guide, they say not to use width and height params but without them, the cropping action dont work ! :x

and with the width and height set, it do works, but not in the right dimensions...on my case, the image gets cut by half in its width set.

have any of u got any solutions?
#5

[eluser]dennismonsewicz[/eluser]
This is what I did

Code:
//Settings to generate thumbnail to work with for cropping
            $config = array();
            $config['image_library'] = 'gd2';
            $config['source_image'] = getcwd() . '/images/gallery/' . $image;
            $config['new_image'] = getcwd() . '/images/gallery/thumb_' . $image;
            $this->image_lib->initialize($config);
            $this->image_lib->resize();
            $this->image_lib->clear();
            
            $this->_moveimage($image, $gallery, false);
            
            //Crop image for online gallery
            $config['image_library'] = 'imagemagick';
            $config['library_path'] = '/opt/local/bin/';
            $config['source_image'] = getcwd() . '/images/gallery/thumb_' . $image;
            $config['maintain_ratio'] = FALSE;
            $config['width'] = 277;
            $config['height'] = 104;
            $config['x_axis'] = 30;
            $config['y_axis'] = 20;
            $this->image_lib->initialize($config);
            
            if(!$this->image_lib->crop()) {
                echo $this->image_lib->display_errors();
            }

If you like, you could post your code and I could take a look at it




Theme © iAndrew 2016 - Forum software by © MyBB