国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

用PHP產生動態的影像圖

瀏覽:69日期:2024-01-20 16:41:54
很多人不了解;;PHP 可以產生非HTML的資料.這是對產生影像圖非常有用的.可以從 database 產生一個簡單的廣告橫圖或更簡單只產生一個圖形按鈕 . 我用 TTF 字型在以下的范例中;;我通常取名作 'button.php3': ####################################################### -----button.php3------ <? ;;Header("Content-type: image/gif"); ;;if(!isset($s)) $s=11; ;;$size = imagettfbbox($s,0,"fonts/TIMES.TTF",$text); ;;$dx = abs($size[2]-$size[0]); ;;$dy = abs($size[5]-$size[3]); ;;$xpad=9; ;;$ypad=9; ;;$im = imagecreate($dx+$xpad,$dy+$ypad); ;;$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); ;;$black = ImageColorAllocate($im, 0,0,0); ;;$white = ImageColorAllocate($im, 255,255,255); ;;ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ;;ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ;;ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "fonts/TIMES.TTF", $text); ;;ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "fonts/TIMES.TTF", $text); ;;ImageGif($im); ;;ImageDestroy($im); ?> ####################################################### 很重要一點是你不能在這檔案中放任何HTML tags.也不能有空白行在 <?和 ?> tag 之前或之後. 如果你用這段Script後看到一個不完整的影像, 表示你可能在PHP標簽以外誤打了字元. 以上的 script 可以由此語法在網頁中叫出來: <IMG SRC="button.php3?s=36&text=PHP+is+Cool">;;####################################################### ----test.php-----;;<html> <head> <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=gb2312"> <title>New Page 1</title> </head> <body>;;<IMG SRC="button.php3?s=36&text=PHP+is+Cool">;;</body> </html> #######################################################;;test.php結果會像這樣: . 's' 參數是設定字型大小 .;;這是當 s=18 時:;;注I: 字型路徑 "/fonts/TIMES.TTF" 可由windows/fonts目錄下取得 TIMS.TTF 字型檔 Copy 至你網站的目錄 fonts下即可測試 至於中文的表現 尚待各位網友提供心得;;注意 我先畫了一個黑色方塊區再用白色位移產生 3D 效果.也陬L法在淺色背景中看出來 但你可以把背景色改為深色看看此效果. 字型也做了同樣效果表現立體感.;;你要先確定你的安裝 PHP 時有設定支援;;GD 和 TTF. 可參考;;PHP FAQ . 我建議可以 copy libgd.a 到;;/usr/local/lib 和 gd*.h 相關檔案到;;/usr/local/include 然後;;;'make install' for FreeTTF library.;;可以在這http://rover.wiesbaden.netsurf.de/~kikita/ 找到釵httf 字型哦! 注: 以下的原始碼改進了上面的弁?可多行文字顯示: ####################################################### --------------button.php----------------- <? Header("Content-type: image/jpeg"); if(!isset($bgred)) $bgred=0; if(!isset($bggreen)) $bggreen=51; if(!isset($bgblue)) $bgblue=153; if(!isset($chred)) $chred=255; if(!isset($chgreen)) $chgreen=255; if(!isset($chblue)) $chblue=255; if(!isset($shadow)) $shadow="yes"if(!isset($wrappos)) $wrappos=20; if(!isset($crop)) $crop=2.2; if(!isset($jpegquality)) $jpegquality=80; if(!isset($s)) $s=11; $savetext=$text; $text=wordwrap($text,$wrappos," ",0); if (!isset($font)) $fontname="/www/ttfonts/arialbd.ttf"else $fontname="/www/ttfonts/".$font.".ttf"$size = imagettfbbox($s,0,$fontname,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $upper=abs($size[5]); $under=$size[1]; $th=$upper-$under; $xpad=9; if (substr_count($text,chr(13))>=1) { ;;$mult=(substr_count($text,chr(13))); ;;$ypad=($mult*$crop*$s)+$s; } else $ypad=($crop-2)*$s; $im = imagecreate($dx+$xpad,$th+$ypad); $color = ImageColorAllocate($im, $bgred,$bggreen,$bgblue); $black = ImageColorAllocate($im, 0,0,0); $fontcolor = ImageColorAllocate($im, $chred,$chgreen,$chblue); ImageRectangle($im,0,0,$dx+$xpad-1,$th+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$th+$ypad,$white); if ($shadow=="yes") ImageTTFText($im, $s, 0, (int)($xpad/2)-2+1, $th+2+(int)($ypad/2)-3, $black, $fontname, $text); ImageTTFText($im, $s, 0, (int)($xpad/2)-2, $th+2+(int)($ypad/2)-1-3, $fontcolor, $fontname, $text); Imagejpeg($im,"",$jpegquality); ImageDestroy($im); ?> ####################################################### 這可以下面這個 form 來產生: ####################################################### ----------test.php-------------------- <html> <head> <title>New Page 1</title> </head> <body> <form method="POST" action="button.php"> <p>文字<input type="text" name="text" size="60"></p> <p>大小<input type="text" name="s" size="6" value="14"></p> <p>斷句的位置(wrap break position) <input type="text" name="wrappos" size="3" value="20"></p> <p>背景顏色</p> <p>紅色<input type="text" name="bgred" size="6" value="0">&nbsp;&nbsp;&nbsp;;;;;;;;綠色<input type="text" name="bggreen" size="8" value="51">&nbsp;&nbsp;&nbsp;;;;;;;;;藍色<input type="text" name="bgblue" size="7" value="153"></p> <p>字元顏色</p> <p>紅色 <input type="text" name="chred" size="6" value="255">&nbsp;&nbsp;&nbsp; ;;;;;;綠色 <input type="text" name="chgreen" size="8" value="255">&nbsp;&nbsp;&nbsp;;;;;;;;藍色 <input type="text" name="chblue" size="7" value="255"></p> <p>字型 <input type="text" name="font" size="20" value="arialbd"></p> <p>陰影 <input type="radio" value="yes" checked name="shadow">是;;;;;;;;;<input type="radio" name="shadow" value="no">否</p> <p>Crop size <input type="text" name="crop" size="20" value="2.2"></p> <p>Jpeg 品質 (0-100) <input type="text" name="jpegquality" size="20" value="80"></p> <p><input type="submit" value="Submit" name="B1"> ;;;;;;<input type="reset" value="Reset" name="B2"></p> </form> </body> </html> ####################################################### 或是直接像上例一樣呼叫:;;####################################################### ----test.php-----;;<html> <head> <title>New Page 1</title> </head> <body>;;<IMG SRC="button.php?s=36&text=PHP+is+Cool">;;</body> </html>;
標簽: PHP
主站蜘蛛池模板: 色偷偷亚洲女人天堂观看欧 | 在线成人亚洲 | 免费欧洲毛片a级视频无风险 | 特级毛片全部免费播放a一级 | 亚洲欧美精品一中文字幕 | 日韩国产欧美一区二区三区 | 午夜一级毛片不卡 | 中文字幕亚洲精品第一区 | 欧美一级毛片100部 欧美一级毛片aaaaa | 亚洲免费视频在线 | 亚洲一区二区三区不卡在线播放 | 在线观看国产精品日本不卡网 | 成人午夜大片免费看爽爽爽 | 99国产高清久久久久久网站 | 久久久久99精品成人片三人毛片 | 欧洲成人全免费视频网站 | 日韩国产免费一区二区三区 | 国产三级国产精品国产国在线观看 | 大片毛片女女女女女女女 | 国产一级大片在线观看 | 91免费国产精品 | 盗摄偷拍a在线观看 | 欧美另类69xxxxx 视频 | 亚洲天堂网在线播放 | 美女被拍拍拍拍拍拍拍拍 | 亚洲精品99久久久久中文字幕 | 午夜寂寞福利 | 美女张开腿让男人桶爽免费网站 | 最新黄网 | 亚洲欧美卡通成人制服动漫 | 成年人免费观看的视频 | 无码孕妇孕交在线观看 | 美女张开腿让男人桶的 视频 | 怡红院成人在线 | 久久九九视频 | 成人午夜视频免费观看 | 99热播 | 精品国产一区二区三区在线观看 | 精品一区二区三区四区在线 | 一区二区三区免费在线视频 | 免费观看成为人视频 |