我正在尝试在上传的图片上添加水印,但它不起作用..有我的代码,我看不到任何错误..
$data['photo_name'] = $data['slogan'];
$data['photo_ext'] = end(explode('.', $photoValue));
$data['photo_name'] = $data['photo_name'] . '.' . $data['photo_ext'];
file_put_contents($_SERVER["DOCUMENT_ROOT"] .'/'. PHOTOS_UPLOAD_FOLDER . $data['photo_name'], file_get_contents($photoValue));
// $this->resize_image($_SERVER["DOCUMENT_ROOT"] .'/'. PHOTOS_UPLOAD_FOLDER . $data['photo_name']);
$this->simpleimage->load($data['photosData']['uploadFolder'] . $data['photo_name']);
$this->simpleimage->cutFromCenter(450, 450);
$this->simpleimage->save($_SERVER["DOCUMENT_ROOT"] .'/'. PHOTOS_UPLOAD_FOLDER . $data['photo_name']);
// add watermark
$configImg = array();
$configImg['image_library'] = 'gd2';
$configImg['wm_type'] = 'overlay';
$configImg['source_image'] = $_SERVER["DOCUMENT_ROOT"] .'/'. PHOTOS_UPLOAD_FOLDER . $data['photo_name'];
$configImg['wm_overlay_path'] = base_url('assets/logo.png');
$configImg['wm_opacity'] = '50';
$configImg['wm_vrt_alignment'] = 'middle';
$configImg['wm_hor_alignment'] = 'center';
$this->image_lib->initialize($configImg);
$this->image_lib->watermark();
$this->image_lib->clear();
$this->image_lib->display_errors();
print_r($configImg);
并且它不会打印任何错误。 它只打印我的数组
Array
(
[image_library] => gd2
[wm_type] => overlay
[source_image] => ../king-include/uploads/possibly-the-best-youtube-comment-ever-.jpg
[wm_overlay_path] => http://www.domain.info/parser/assets/logo.png
[wm_opacity] => 100
[wm_vrt_alignment] => top
[wm_hor_alignment] => center
)
答案 0 :(得分:2)
source_image:设置源图像名称/路径。路径必须是相对或绝对服务器路径,而不是URL。
问题在于水印叠加图像。使用正确的路径进行设置,然后重试。