[eluser]AdamCMills[/eluser]
Verified, using the same variable to redisplay the image "on success".
I can accomplish the resize functionality just fine, just the crop code seems to do nothing. I'm wondering if maybe it was a typo in the documentation?
It does seem to be missing something ... the reason I say this is...
It gets a X axis, it gets a Y axis, but it doesn't get a height and width to base the other two points for a crop off of. I just don't under stand how the code would know unless it assumes you are cropping a specific size.
And it seems this is the case ... inside the image_process_gd function in the Image_lib.php libarary file ... line 448:
line 453:
Code:
// If the target width/height match the source, AND if the new file name is not equal to the old file name
// we'll simply make a copy of the original with the new name... assuming dynamic rendering is off.
if ($this->dynamic_output === FALSE)
{
if ($this->orig_width == $this->width AND $this->orig_height == $this->height)
{
if ($this->source_image != $this->new_image)
{
if (@copy($this->full_src_path, $this->full_dst_path))
{
@chmod($this->full_dst_path, DIR_WRITE_MODE);
}
}
return TRUE;
}
}
So the if statement on line 472 never gets execture because you didn't set a height and width.
RESOLVED:
Despite documentation had to set height and width and the maintain ratio to false ... my workign code looks like this:
Code:
function crop(){
$config['image_library'] = 'gd2';
$config['source_image'] = $this->session->flashdata('file');
$config['x_axis'] = $_POST['x'];
$config['y_axis'] = $_POST['y'];
$config['height'] = $_POST['h'];
$config['width'] = $_POST['w'];
$config['maintain_ratio'] = FALSE;
$this->load->library('image_lib');
$this->image_lib->initialize($config);
if ( ! $this->image_lib->crop())
{
echo $this->image_lib->display_errors();
}
echo '<img src="'.substr($config['source_image'],1).'" />';
}