我在这里遇到一些麻烦,我希望上传我的图像,并对图像进行裁剪和加水印。这是我的控制器代码
//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() ;
所有代码都很好,没有发现错误,代码只创建水印而没有裁剪,但是当我在裁剪代码之上反转水印代码时,结果只是裁剪图像。
那么我必须做什么,我可以一次上传带有裁剪和水印的图像?
提前致谢
答案 0 :(得分: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() ;