我使用JCrop插件,看看他们的PHP裁剪例子。 基本上,当你选择要裁剪时会发生什么,它将被保存在X,Y为坐标,H,W为高度和宽度。
Codeigniter的image_lib提供了裁剪或调整图像大小的简单方法。阅读文档为..
我的代码片段:
//crop it
$data['x'] = $this->input->post('x');
$data['y'] = $this->input->post('y');
$data['w'] = $this->input->post('w');
$data['h'] = $this->input->post('h');
$config['image_library'] = 'gd2';
//$path = 'uploads/apache.jpg';
$config['source_image'] = 'uploads/'.$data['user_data']['img_link']; //http://localhost/resume/uploads/apache.jpg
// $config['create_thumb'] = TRUE;
//$config['new_image'] = './uploads/new_image.jpg';
$config['maintain_ratio'] = FALSE;
$config['width'] = $data['w'];
$config['height'] = $data['h'];
$config['x_axis'] = $data['x'];
$config['y_axis'] = $data['y'];
$this->load->library('image_lib', $config);
if(!$this->image_lib->crop())
{
echo $this->image_lib->display_errors();
}
redirect('profile');
这里原载图像裁剪,你还可以创建新的图像。只需为此创建create_thumb = true即可。
我想要图像链接...... – Ebrahim
谢谢。我有同样的问题。 – Gereltod