如何在Codeigniter中创建一个图像水印wm_type重叠? [英] How to create an image watermark wm_type overlay in Codeigniter?

查看:626
本文介绍了如何在Codeigniter中创建一个图像水印wm_type重叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把图像放在另一个图像(水印)上,像这样:


  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);
}

}

但我不断收到错误: / p>

 遇到PHP错误
严重性:警告
消息:imagecolorat()期望参数1为资源,布尔给定
文件名:libraries / Image_lib.php
行号:941
遇到PHP错误
严重性:警告
消息:imagecolorat()期望参数1文件名:libraries / Image_lib.php
行号:953
遇到PHP错误
严重性:警告
消息:imagecolortransparent()期望参数1是资源,布尔给定
文件名:libraries / Image_lib.php
行号:953
遇到PHP错误
严重性:警告
消息: imagecopymerge()期望参数1是资源,布尔给定
文件名:libraries / Image_lib.php
行号:954
图像的路径不正确。
图像的路径不正确。
图像的路径不正确。
您的服务器不支持处理此类型映像所需的GD函数。
您的服务器不支持处理此类型映像所需的GD函数。
您的服务器不支持处理此类型映像所需的GD函数。

解决方案



问题就像删除正斜杠一样简单(虽然在文档示例正斜杠存在)在他开始像这样:

  $ 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函数。


我从来没有想过这只是一个路径问题,当我看到上面的错误。


I am trying to put an image over another image (watermark) like so:

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);
    }

}

but I keep getting errors:

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.

What am I missing?

解决方案

The issue was as simple as removing the forward slash (although in the documentation example the forward slash exists) at he beginning like so:

$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';

what got me confused this error:

Your server does not support the GD function required to process this type of image.

I never thought it was only a path issue when I saw the error above.

这篇关于如何在Codeigniter中创建一个图像水印wm_type重叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆