我正在上传一个图像使用CI上传库工作得很好,水印和图像缩略图的问题,如果id做水印首先,然后缩略图,它做水印的原始图像,但也重新调整它的缩略图大小,但不保留原始大小的图像与水印,如果我做缩略图,然后水印它工作很好,但我想缩略图也水印这里是我的代码
$this->do_thumb('file_name');
$this->watermark('file_name');
function watermark($filename){
$image_cfg = array();
$image_cfg['image_library'] = 'GD2';
$image_cfg['source_image'] = 'upload/' . $filename;
$image_cfg['wm_overlay_path'] = 'upload/watermark.png';
$image_cfg['new_image'] = 'upload/mark_'.$filename;
$image_cfg['wm_type'] = 'overlay';
$image_cfg['wm_opacity'] = '10';
$image_cfg['wm_vrt_alignment'] = 'bottom';
$image_cfg['wm_hor_alignment'] = 'right';
$image_cfg['create_thumb'] = FALSE;
$this->image_lib->initialize($image_cfg);
$this->image_lib->watermark();
$this->image_lib->clear();
// echo $this->image_lib->display_errors();
// die();
}
function do_thumb($filename) {
$image_cfg['image_library'] = 'GD2';
$image_cfg['source_image'] = 'upload/' . $filename;
$image_cfg['create_thumb'] = TRUE;
$image_cfg['maintain_ratio'] = TRUE;
$image_cfg['width'] = '200';
$image_cfg['height'] = '175';
$this->load->library('image_lib');
$this->image_lib->initialize($image_cfg);
$this->image_lib->resize();
$this->image_lib->clear();
}发布于 2013-02-12 19:47:27
首先执行watermark(),然后执行do_thumb(),在水印函数处删除$image_cfg['new_image'],或者如果你想使用它,将$image_cfg['new_image']值传递给do_thumb()。
另外,不要忘记在do_thumb()中设置$image_cfg['new_image'],这样它就会创建新的thumb文件,而不是重写它
拇指没有包含水印的问题是因为您使用原始图像而不是水印图像作为拇指的图像源。希望你能理解我的意思,因为英语不是我的第一语言,php才是..
https://stackoverflow.com/questions/12702234
复制相似问题