我想在新上传的图片上添加水印。我正在使用CI。
public function watermark(){
$this->load->library('image_lib');
$config['source_image'] = 'uploads/gallery/d7315a9a3039541431ab8a41820b6f00.jpg';
$config['wm_text'] = 'Copyright 2015';
$config['wm_type'] = 'text';
$config['wm_font_size'] = 16;
$config['wm_font_color'] = 'ffffff';
$config['wm_vrt_alignment'] = 'middle';
$config['wm_hor_alignment'] = 'right';
$config['wm_padding'] = '20';
$this->image_lib->initialize($config);
if (!$this->image_lib->watermark()) {
echo $this->image_lib->display_errors();
}else{
echo "Image created";
}
}
它没有显示任何错误,但未创建图像。
答案 0 :(得分:0)
答案 1 :(得分:0)
试试这个
public function image_watermark()//change the class name
{
$this->load->library('image_lib');
$config['source_image'] = 'uploads/gallery/d7315a9a3039541431ab8a41820b6f00.jpg';
$config['wm_text'] = 'Copyright 2015';
$config['wm_type'] = 'text';
$config['wm_font_size'] = 16;
$config['wm_font_color'] = 'ffffff';
$config['wm_vrt_alignment'] = 'middle';
$config['wm_hor_alignment'] = 'right';
$config['wm_padding'] = '5';//less padding
$this->image_lib->initialize($config);
if (!$this->image_lib->watermark()) {
echo $this->image_lib->display_errors();
}else{
echo "Image created";
}
}