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

[eluser]dennismonsewicz[/eluser]
I have been developing some code that I need to crop a picture section of an image (a specific width and height)... can this be done using CI's Image Library?

I have given it much thought and trial but cannot make it happen

I have attached two images, the full image and a section of the image, to show what I would like to accomplish.

Here is my code thus far

Code:
//Settings to create watermark overlay
            $config = array();
            $config['image_library'] = 'gd2';
            $config['source_image'] = $data['json']->{'file_path'};
            $config['x_axis'] = 30;
            $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);
#2

[eluser]treeface[/eluser]
Hi Dennis,

What happens when you run this code?
#3

[eluser]dennismonsewicz[/eluser]
Thanks for the reply!

I have attached the before and after photo of passing it through my script

It seems to add a black border around the image...

Any ideas?
#4

[eluser]treeface[/eluser]
Hm...actually, if I'm not mistaken, it seems to be moving the image up and to the left, leaving a black area where the image used to be. It also seems to be compressing it along the x axis, but I'm not so sure about that.

You'll have to excuse me, I've never used CI's image library, but what's the reason for using the gd2 library instead of the ImageMagick library? I noticed that in the user guide they use the imagemagick one for cropping. Dunno if that'll make a difference...
#5

[eluser]dennismonsewicz[/eluser]
I honestly have not tried using imagemagick... I will give that a try. Thanks!
#6

[eluser]umefarooq[/eluser]
try crop with image width and height don't use axis in config and check the results i have done some crop with CI image library with width and height with maintain ratio false check here small thumbnails in gallery

http://webmasterdubai.com/ultimate/yacht...onlight-ii




Theme © iAndrew 2016 - Forum software by © MyBB