1

我在这里遇到了一点麻烦,我想上传我的图像,并对图像进行裁剪和水印。这是我的控制器代码

//cropping image
$img['maintain_ratio'] = FALSE;
$img['create_thumb'] = TRUE;
$img['width'] = $thumb_size;
$img['height'] = $thumb_size;            
$this->image_lib->initialize($img);
$this->image_lib->crop();
$this->image_lib->clear();
$img['source_image'] = $source ;

//watermark image
$img['new_image']    = $destination_thumb ;
$img['wm_overlay_path'] = './images/resource/watermark.png';
$img['wm_type'] = 'overlay';
$img['wm_vrt_alignment'] = 'midle';
$img['wm_hor_alignment'] = 'center';
$this->image_lib->initialize($img);
$this->image_lib->watermark();            
$this->image_lib->clear() ;

所有代码都很好,没有发现错误,代码只是创建水印而不裁剪,但是当我在裁剪代码上面反转水印代码时,结果只是裁剪图像。

那么我必须做些什么才能一次上传带有裁剪和水印的图像?

提前致谢

4

1 回答 1

0

你能试试这个:

$img['source_image'] = $source ;

$img['maintain_ratio'] = FALSE;
$img['create_thumb'] = TRUE;
$img['width'] = $thumb_size;
$img['height'] = $thumb_size;            
$this->image_lib->initialize($img);
$this->image_lib->crop();
$this->image_lib->clear();


//watermark image
$img['new_image']    = $destination_thumb ;
$img['wm_overlay_path'] = './images/resource/watermark.png';
$img['wm_type'] = 'overlay';
$img['wm_vrt_alignment'] = 'midle';
$img['wm_hor_alignment'] = 'center';
$this->image_lib->initialize($img);
$this->image_lib->watermark();            
$this->image_lib->clear() ;
于 2012-12-29T15:01:30.663 回答