我正在尝试将图像放在另一个图像(水印)上,如下所示:
class Water_mark extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
$this->load->library('image_lib');
$config['image_library'] = 'GD2';
$config['source_image'] = '/assets/images/tv-share.jpg';
$config['new_image'] = '/assets/images/tv-share-done.jpg';
$config['wm_type'] = 'overlay';
$config['wm_overlay_path'] = '/assets/images/share_en.jpg';
$config['wm_opacity'] = '50';
$config['wm_vrt_alignment'] = 'top';
$config['wm_hor_alignment'] = 'left';
$config['wm_hor_offset'] = '10';
$config['wm_vrt_offset'] = '10';
$data = $config;
$this->image_lib->initialize($config);
if (!$this->image_lib->watermark()) {
echo $this->image_lib->display_errors();
}
$this->image_lib->clear();
$this->load->view('water_mark_view', $data);
}
}
但我不断收到错误:
A PHP Error was encountered
Severity: Warning
Message: imagecolorat() expects parameter 1 to be resource, boolean given
Filename: libraries/Image_lib.php
Line Number: 941
A PHP Error was encountered
Severity: Warning
Message: imagecolorat() expects parameter 1 to be resource, boolean given
Filename: libraries/Image_lib.php
Line Number: 953
A PHP Error was encountered
Severity: Warning
Message: imagecolortransparent() expects parameter 1 to be resource, boolean given
Filename: libraries/Image_lib.php
Line Number: 953
A PHP Error was encountered
Severity: Warning
Message: imagecopymerge() expects parameter 1 to be resource, boolean given
Filename: libraries/Image_lib.php
Line Number: 954
The path to the image is not correct.
The path to the image is not correct.
The path to the image is not correct.
Your server does not support the GD function required to process this type of image.
Your server does not support the GD function required to process this type of image.
Your server does not support the GD function required to process this type of image.
我想念什么?
问题很简单,就像在开始时就删除正斜杠一样(尽管在文档示例中正斜杠存在):
$config['source_image'] = 'assets/images/tv-share.jpg';
$config['new_image'] = 'assets/images/tv-share-done.jpg';
$config['wm_overlay_path'] = 'assets/images/share_en.jpg';
是什么让我困惑这个错误:
您的服务器不支持处理此类图像所需的GD功能。
当我看到上面的错误时,我从未想过这仅仅是路径问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句