成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

百度編輯器添加水印方法

鄭州高端網(wǎng)站定制制作網(wǎng)站的時(shí)候,遇到百度編輯器需要添加水印,可是百度編輯器本身沒有添加水印的功能,這個(gè)時(shí)候就需要添加了。以下是方法。

為朗縣等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及朗縣網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為網(wǎng)站制作、做網(wǎng)站、朗縣網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

1、找到config.json的文件,在第一行的時(shí)候,添加"iswatermark": "true",

2、找到這段代碼

$base64 = "upload";

switch (htmlspecialchars($_GET['action'])) {

    case 'uploadimage':

        $config = array(

            "pathFormat" => $CONFIG['imagepathFormat'],

            "maxSize" => $CONFIG['imageMaxSize'],

            "allowFiles" => $CONFIG['imageAllowFiles']

        );

        $fieldName = $CONFIG['imageFieldName'];

        $watermark = $CONFIG['iswatermark'];

        break;

3、找到這段代碼

$up = new Uploader($fieldName, $config, $base64, $watermark);

4、找到Uploader.class.php這個(gè)文件

5、添加屬性

private $water;

6、找到upFile()這個(gè)函數(shù)

在這個(gè)函數(shù)的最后一段代碼后面添加

if($this->water){

            $this->watermark($this->filepath,$this->filepath);

        }

7、找到這個(gè)類里面的構(gòu)造函數(shù),修改這個(gè)頭

public function __construct($fileField, $config, $type = "upload", $watermark = false )

8、在這個(gè)類里面的最后一個(gè)函數(shù)后面,添加兩個(gè)函數(shù)

    public function watermark($source, $target = '', $w_pos = '', $w_img = '', $w_text = 'www.aiyu.com',$w_font = 10, $w_color = '#CC0000') {

        $this->w_img = src="/upload/article1/makk.png';//水印圖片

        $this->w_pos = 9;

        $this->w_minwidth = 200;//最少寬度

        $this->w_minheight = 100;//最少高度

        $this->w_quality = 80;//圖像質(zhì)量

        $this->w_pct = 85;//透明度

        $w_pos = $w_pos ? $w_pos : $this->w_pos;

        $w_img = $w_img ? $w_img : $this->w_img;

        if(!$this->check($source)) return false;

        if(!$target) $target = $source;

        $source_info = getimagesize($source);//圖片信息

        $source_w  = $source_info[0];//圖片寬度

        $source_h  = $source_info[1];//圖片高度

        if($source_w < $this->w_minwidth || $source_h < $this->w_minheight) return false;

        switch($source_info[2]) { //圖片類型

            case 1 : //GIF格式

                $source_img = imagecreatefromgif($source);

                break;

            case 2 : //JpG格式

                $source_img = imagecreatefromjpeg($source);

                break;

            case 3 : //pNG格式

                $source_img = imagecreatefrompng($source);

//imagealphablending($source_img,false); //關(guān)閉混色模式

                imagesavealpha($source_img,true); //設(shè)置標(biāo)記以在保存 pNG 圖像時(shí)保存完整的 alpha 通道信息(與單一透明色相反)

                break;

            default :

                return false;

        }

        if(!empty($w_img) && file_exists($w_img)) { //水印圖片有效

            $ifwaterimage = 1; //標(biāo)記

            $water_info  = getimagesize($w_img);

            $width    = $water_info[0];

            $height    = $water_info[1];

            switch($water_info[2]) {

                case 1 :

                    $water_img = imagecreatefromgif($w_img);

                    break;

                case 2 :

                    $water_img = imagecreatefromjpeg($w_img);

                    break;

                case 3 :

                    $water_img = imagecreatefrompng($w_img);

                    imagealphablending($water_img,false);

                    imagesavealpha($water_img,true);

                    break;

                default :

                    return;

            }

        }else{

            $ifwaterimage = 0;

            $temp = imagettfbbox(ceil($w_font*2.5), 0, '../../texb.ttf', $w_text); //imagettfbbox返回一個(gè)含有 8 個(gè)單元的數(shù)組表示了文本外框的四個(gè)角

            $width = $temp[2] - $temp[6];

            $height = $temp[3] - $temp[7];

            unset($temp);

        }

        switch($w_pos) {

            case 1:

                $wx = 5;

                $wy = 5;

                break;

            case 2:

                $wx = ($source_w - $width) / 2;

                $wy = 0;

                break;

            case 3:

                $wx = $source_w - $width;

                $wy = 0;

                break;

            case 4:

                $wx = 0;

                $wy = ($source_h - $height) / 2;

                break;

            case 5:

                $wx = ($source_w - $width) / 2;

                $wy = ($source_h - $height) / 2;

                break;

            case 6:

                $wx = $source_w - $width;

                $wy = ($source_h - $height) / 2;

                break;

            case 7:

                $wx = 0;

                $wy = $source_h - $height;

                break;

            case 8:

                $wx = ($source_w - $width) / 2;

                $wy = $source_h - $height;

                break;

            case 9:

                $wx = $source_w - ($width+5);

                $wy = $source_h - ($height+5);

                break;

            case 10:

                $wx = rand(0,($source_w - $width));

                $wy = rand(0,($source_h - $height));

                break;

            default:

                $wx = rand(0,($source_w - $width));

                $wy = rand(0,($source_h - $height));

                break;

        }

        if($ifwaterimage) {

            if($water_info[2] == 3) {

                imagecopy($source_img, $water_img, $wx, $wy, 0, 0, $width, $height);

            }else{

                imagecopymerge($source_img, $water_img, $wx, $wy, 0, 0, $width, $height, $this->w_pct);

            }

        }else{

            if(!empty($w_color) && (strlen($w_color)==7)) {

                $r = hexdec(substr($w_color,1,2));

                $g = hexdec(substr($w_color,3,2));

                $b = hexdec(substr($w_color,5));

            }else{

                return;

            }

            imagestring($source_img,$w_font,$wx,$wy,$w_text,imagecolorallocate($source_img,$r,$g,$b));

        }

        switch($source_info[2]) {

            case 1 :

                imagegif($source_img, $target);

//GIF 格式將圖像輸出到瀏覽器或文件(欲輸出的圖像資源, 指定輸出圖像的文件名)

                break;

            case 2 :

                imagejpeg($source_img, $target, $this->w_quality);

                break;

            case 3 :

                imagepng($source_img, $target);

                break;

            default :

                return;

        }

        if(isset($water_info)){

            unset($water_info);

        }

        if(isset($water_img)) {

            imagedestroy($water_img);

        }

        unset($source_info);

        imagedestroy($source_img);

        return true;

    }

    public function check($image){

        return extension_loaded('gd') && preg_match("/\.(jpg|jpeg|gif|png)/i", $image, $m) && file_exists($image) && function_exists('imagecreatefrom'.($m[1] == 'jpg' ? 'jpeg' : $m[1]));

    }

網(wǎng)頁題目:百度編輯器添加水印方法
網(wǎng)頁路徑:http://jinyejixie.com/article24/sccgce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站營(yíng)銷App開發(fā)、電子商務(wù)、小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
苗栗市| 罗定市| 邻水| 长丰县| 柳河县| 旌德县| 两当县| 车致| 沛县| 扬中市| 蒙城县| 桂阳县| 鄱阳县| 清水河县| 额尔古纳市| 泸水县| 东莞市| 崇阳县| 西安市| 普定县| 永春县| 武安市| 理塘县| 乌兰察布市| 安达市| 四川省| 苗栗市| 砀山县| 潞西市| 济阳县| 江孜县| 仙游县| 郧西县| 福贡县| 石泉县| 丹凤县| 水富县| 聂荣县| 邵东县| 宜章县| 兰考县|