|
请问使用图片处理类的时候可不可以对一张图片同事进行多项操作?
比较:对test.jpg进行缩放+剪裁+水印文字,我使用两种以上操作的时候好像只有最后一个有效果。
帖一下代码
PHP复制代码
$this->load->library('image_lib');
$post = $this->input->post();
$config['image_library'] = 'gd2';
$config['source_image'] = $post['imageSource'];
$config['thumb_marker'] = '_' . rand(1, 10000);
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = $_POST['selectorW'];
$config['height'] = $_POST['selectorH'];
$config['create_thumb'] = true;
$config['wm_text'] = 'Copyright 2007 - David Upton';
$config['wm_type'] = 'text';
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
if ( ! $this->image_lib->resize() || ! $this->image_lib->watermark()){
echo $this->image_lib->display_errors();
}else{
$str = end(explode(".",$config['source_image']));
$image = explode('.'.$str, $config['source_image']);
$image = $image[0].$config['thumb_marker'].'.'.$str;
$data = array('img' => $image, 'width' => $config['width']+28, 'height' => $config['height']+58);
exit(json_encode($data));
}
复制代码
|
|