CodeIgniter image crop only on dynamic output
I'm trying to crop an image in CodeIgniter, using the built in image manipulation class. The code below works fine, you get a resized image output to the browser. However, when you remove the "$config['dynamic_output'] = TRUE;
" line it no longer crops the image, and just saves the original image instead. What am I doing wrong?!
Any help is much appreciate开发者_运维问答d, thanks!
public function crop() {
$config['library_path'] = '/usr/local/bin';
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/static/images/moose_resized.jpg';
$config['new_image'] = $_SERVER['DOCUMENT_ROOT'].'/static/images/moose_thumb.jpg';
$config['x_axis'] = '0';
$config['y_axis'] = '74';
$config['width'] = '222';
$config['height'] = '111';
$config['maintain_ratio'] = FALSE;
$config['quality'] = '100';
$config['dynamic_output'] = TRUE;
$this->load->library('image_lib', $config);
$this->image_lib->crop();
if ( ! $this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
$this->load->view('crop');
}
OK, so nobody get any points because they didn't spot the stupid mistake in the code above!
$this->image_lib->crop();
if ( ! $this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
In a moment of temporary insanity I added in the crop line, rather than replacing the resize one in the if statement. Duh!
精彩评论