第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

【學習打卡】第17天 PHP進階篇-GD庫圖像處理

课程名称:PHP进阶篇-GD库图像处理

课程章节:第3章 图像常用操作

主讲老师:king

课程内容:

今天学习的内容包括:

  • 3-6 文字水印的封装及测试

  • 3-7 图片水印的实现

  •  图片水印的封装及测试

课程收获:

我的环境是 php 8.19 nts版本  

文字水印函数封装 图片水印函数的封装
//文字水印
/**
 * 文字水印
 * @param $filename
 * @param $fontfile
 * @param $text
 * @param $dest
 * @param $pre
 * @param $delsource
 * @param $r
 * @param $g
 * @param $b
 * @param $alpha
 * @param $size
 * @param $angle
 * @param $x
 * @param $y
 * @return string
 */
function water_text($filename,$fontfile,$text = '佳和信息',$dest = 'waterText',$pre = 'waterText_',$delsource=false,$r = 255,$g = 0,$b = 0,$alpha = 60, $size = 30, $angle = 0,$x = 0,$y = 30)
{
    //$filename = 'images/1.jpg';
//    $r = 255;
//    $g = 0;
//    $b = 0;
//    $alpha = 60;
//    $size = 30;
//    $angle = 0;
//    $x = 0;
//    $y = 30;
    //$fontfile = 'fonts/kaiti.ttc';
    //$text = '佳和信息';
    $fileInfo = getImageInfo($filename);
    $image = $fileInfo['createFun']($filename);
    $color = imagecolorallocatealpha($image, $r, $g, $b, $alpha);
    imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text);
    //$dest = 'waterText';
    //$pre = 'waterText_';
    if ($dest && !file_exists($dest)) {
        mkdir($dest, 0777, true);
    }
    $randNum = mt_rand(100000, 999999);
    $dstName = "{$pre}{$randNum}" . $fileInfo['ext'];
    $destination = $dest ? $dest . '/' . $dstName : $dstName;
    $fileInfo['outFun']($image, $destination);
    imagedestroy($image);
    if ($delsource) {
        @unlink($filename);
    }
    return $destination;
}
function water_pic($dstName,$srcName,$pos=0,$dest = 'waterPic',$pre = 'waterPic_',$pct=50,$delsource=false){
//    $dstName='1.jpg';
//    $srcName='jdlogo.png';
//    $pos=0;
//    $pct=50;
//    $dest = 'waterPic';
//    $pre = 'waterPic_';
//    $delsource=false;
    $dstInfo=getImageInfo($dstName);
    $srcInfo=getImageInfo($srcName);
    $dst_im=$dstInfo['createFun']($dstName);
    $src_im=$srcInfo['createFun']($srcName);
    $src_width=$srcInfo['width'];
    $src_height=$srcInfo['height'];
    $dst_width=$dstInfo['width'];
    $dst_height=$dstInfo['height'];
    switch ($pos){
        case 0:
            $x=0;
            $y=0;
        break;
        case 1:
            $x=($dst_width-$src_width)/2;
            $y=0;
        break;
        case 2:
            $x=$dst_width-$src_width;
            $y=0;
        break;
        case 3:
            $x=0;
            $y=($dst_height-$src_height)/2;
        break;
        case 4:
            $x=($dst_width-$src_width)/2;
            $y=($dst_height-$src_height)/2;
        break;
        case 5:
            $x=$dst_width-$src_width;
            $y=($dst_height-$src_height)/2;
        break;
        case 6:
            $x=0;
            $y=$dst_height-$src_height;
        break;
        case 7:
            $x=($dst_width-$src_width)/2;
            $y=$dst_height-$src_height;
        break;
        case 8:
            $x=$dst_width-$src_width;
            $y=$dst_height-$src_height;
        break;
        default:
            $x=0;
            $y=0;
        break;
    }
    imagecopymerge($dst_im,$src_im,$x,$y,0,0,$src_width,$src_height,$pct);
    if ($dest && !file_exists($dest)) {
        mkdir($dest, 0777, true);
    }
    $randNum = mt_rand(100000, 999999);
    $dstName = "{$pre}{$randNum}" . $dstInfo['ext'];
    $destination = $dest ? $dest . '/' . $dstName : $dstName;
    $dstInfo['outFun']($dst_im,$destination);
    imagedestroy($src_im);
    imagedestroy($dst_im);
    if ($delsource) {
        @unlink($dstName);
    }
    return $destination;

}


點擊查看更多內(nèi)容
2人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優(yōu)惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消