Welcome Guest, Not a member yet? Register   Sign In
image_lib crop method with GD
#1

[eluser]kenjis[/eluser]
Sample code in User Guide:
Code:
$config['image_library'] = 'imagemagick';
$config['library_path'] = '/usr/X11R6/bin/';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['x_axis'] = '100';
$config['y_axis'] = '60';

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

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

Above code doesn't work with GD.
Because of below code, function image_process_gd in image_lib.php.
If there is no $config['width'] nor $config['height'], then,
$this->width = $this->orig_width and $this->height = $this->orig_height.

Code:
// If the target width/height match the source then it's pointless to crop, right?
            if ($this->width >= $this->orig_width AND $this->height >= $this->orig_height)
            {
                // We'll return true so the user thinks the process succeeded.
                // It'll be our little secret...
    
                return TRUE;
            }

Only crop method with GD needs $config['width'] and $config['height'].
Is this a bug? or spec?
#2

[eluser]Derek Allard[/eluser]
Thanks Kenji. I could have sworn I got that one already.

Could I ask you to search the bug tracker, and if you don't see it there to add it. Thanks!
#3

[eluser]kenjis[/eluser]
User Guide says in $this->image_lib->crop() section:
All preferences listed in the table above are available for this function except these: rotation, width, height, create_thumb, new_image.

So this is a bug, isn't it?

And I've found new_image can be used in crop method.
#4

[eluser]kenjis[/eluser]
Hi, Derek. Thank you for your comment.

[quote author="Derek Allard" date="1198088500"]Thanks Kenji. I could have sworn I got that one already.

Could I ask you to search the bug tracker, and if you don't see it there to add it. Thanks![/quote]

You are right. This must be.

http://codeigniter.com/bug_tracker/bug/2588/
#5

[eluser]Michael Wales[/eluser]
I've noticed quite a few bugs with the Image library (mainly with numerous parameters being available, sometimes even required, but the documentation doesn't list those as available parameters for the method you intend to use). I'll need to go through the image_lib soon and document all of these, for starters: http://codeigniter.com/bug_tracker/bug/3147/

It's really odd that the resize() method requires both height/width, then CI magically tries to come as close to those dimensions. I can't think of a single instance where I know what both the height/width of the resized image should be - maybe it's assumed the third-party libraries (GD, ImageMagick, etc) figure it out dynamically? I'm unsure.

In my experience, resizing is very "hit-or-miss" when you really only rely on one paramater. The changes outlined in the bug report above (just a logical example, it is untested code - please help in testing) should allow the developer to provide one parameter (height or width) and dynamically generate the other.

For example: I know I want avatars on my site no more than 80px wide, but I am allowing people to upload any size image they want. Since I am not locking them down to a specific ratio (of height to width), I must dynamically generate the height parameter of the new image based on a resize width of 80.




Theme © iAndrew 2016 - Forum software by © MyBB