久久久久在线观看_又色又爽又黄的免费视频播放_一区中文字幕_日韩电影在线播放

今日頭條 焦點資訊 營銷之道 企業報道 淘寶運營 網站建設 軟件開發 400電話
  當前位置: 首頁 » 資訊 » 軟件開發 » 正文

php字符串生成圖片實例詳解

放大字體  縮小字體 發布日期:2018-03-03  來源:企業800網  作者:新格網  瀏覽次數:984  【去百度看看】
核心提示:本文主要和大家分享php字符串生成圖片實例詳解,希望能幫助到大家。
本文主要和大家分享php字符串生成圖片實例詳解,希望能幫助到大家。

function generateImg($source, $text1, $text2, $text3, $font = './msyhbd.ttf') {    $date = '' . date ( 'Ymd' ) . '/';    $img = $date . md5 ( $source . $text1 . $text2 . $text3 ) . '.jpg';    if (file_exists ( './' . $img )) {        return $img;
    } 
    $main = imagecreatefromjpeg ( $source ); 
    $width = imagesx ( $main );    $height = imagesy ( $main ); 
    $target = imagecreatetruecolor ( $width, $height ); 
    $white = imagecolorallocate ( $target, 255, 255, 255 );
    imagefill ( $target, 0, 0, $white );
 
    imagecopyresampled ( $target, $main, 0, 0, 0, 0, $width, $height, $width, $height ); 
    $fontSize = 18;//像素字體
    $fontColor = imagecolorallocate ( $target, 255, 0, 0 );//字的RGB顏色
    $fontBox = imagettfbbox($fontSize, 0, $font, $text1);//文字水平居中實質
    imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 190, $fontColor, $font, $text1 ); 
    $fontBox = imagettfbbox($fontSize, 0, $font, $text2);
    imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 370, $fontColor, $font, $text2 ); 
    $fontBox = imagettfbbox($fontSize, 0, $font, $text3);
    imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 560, $fontColor, $font, $text3 ); 
    //imageantialias($target, true);//抗鋸齒,有些PHP版本有問題,謹慎使用 
    imagefilledpolygon ( $target, array (10 + 0, 0 + 142, 0, 12 + 142, 20 + 0, 12 + 142), 3, $fontColor );//畫三角形
    imageline($target, 100, 200, 20, 142, $fontColor);//畫線
    imagefilledrectangle ( $target, 50, 100, 250, 150, $fontColor );//畫矩形
 
    //bof of 合成圖片
    $child1 = imagecreatefromjpeg ( 'http://gtms01.alicdn.com/tps/i1/T1N0pxFEhaXXXxK1nM-357-88.jpg' );
    imagecopymerge ( $target, $child1, 0, 400, 0, 0, imagesx ( $child1 ), imagesy ( $child1 ), 100 );    //eof of 合成圖片 
    @mkdir ( './' . $date );
    imagejpeg ( $target, './' . $img, 95 );
 
    imagedestroy ( $main );
    imagedestroy ( $target );
    imagedestroy ( $child1 );    return $img;
}generateImg ( 'https://ssl.picture.qingger.com/Fi8zMItS5c_Uvm7WueZ5z_0VsDg_', 'aaaaa', 'PHP文字水平居中', '3個字' );exit ();

相關推薦:

PHP實現生成圖片縮略圖函數

node實現文字生成圖片代碼分享

利用php 內置函數生成圖片的方法實例詳解

以上就是php字符串生成圖片實例詳解的詳細內容,更多請關注php中文網其它相關文章!

 
關鍵詞: 字符串,php,詳解
 
[ 資訊搜索 ]  [ 加入收藏 ]  [ 告訴好友 ]  [ 打印本文 ]  [ 違規舉報 ]  [ 關閉窗口 ]

 
0條 [查看全部]  相關評論

 
網站首頁 | 關于我們 | 聯系方式 | 使用協議 | 版權隱私 | 網站地圖 | 排名推廣 | 廣告服務 | 積分換禮 | 網站留言 | RSS訂閱 | 吉ICP備11001726號-6
企業800網 · 提供技術支持