❶ php imagefttext 怎麼使用默認字體
友慎如果你的系統是redhat linux 8.0 , 並且apache是系統預設安裝的,你可以到 /etc/httpd/conf/httpd.conf 文件里,把AddDefaultCharset 的預設字元集改成你想要的,搏告掘(如:gb2312).保存文基核件,重起apache 就可以了。
❷ ID666免費空間PHP驗證碼路徑怎麼寫
嗯嗯,請採納
❸ imagefttext生成水印怎麼保存 php的
/*打開圖片*/
1配置圖片路徑(就是你想要操作的圖片的路徑)
2獲取圖片信息(通過GD庫的方法,得到你想要處理氏帆的圖片的基本信息)
3通過圖像的編碼來獲取圖像的類型
4在內存中創建一個和我們圖片類型一樣的圖像
5把圖片復制到內存中
/*操作圖片*/
1設置字體路徑
2填寫我們水印的內容
3設置字體的的顏色和透明度
4將字體中行向圖片寫入文字
/*輸出圖片*/
1瀏覽器輸出
2保存圖片
/*銷毀圖片*/
<?php
$src="img/Porsche-911.jpg";
$info=getimagesize($src);
$type=image_type_to_extension($info[2],false);
$fun="imagecreatefrom{$type}";//$fun=imagecreatefromjpeg;$fun=imagecreatefrompng
$image=$fun($src);
$font="fonts/MSYHL.TTC";
$content="賣核嘩你好,NeiVan";
$color=imagecolorallocatealpha($image,255,255,255,50);
imagettftext($image,20,0,100,50,$color,$font,$content);
header('content-type:'.$info['mime']);
$func="image{$type}";//imagejpegimagepngimagegif
$func($image);
$func($image,'newimage'.$type);
imagedestroy($image);
?>
❹ PHP圖像處理函數有哪些
php圖像處理函數大全
php圖片處理代碼分享,包括縮放、剪裁、縮放、翻轉、旋轉、透明、銳化等。需要的朋友可以參考下
一、創建圖片資源
imagecreatetruecolor(width,height);
imagecreatefromgif(圖片名稱);
imagecreatefrompng(圖片名稱);
imagecreatefromjpeg(圖片名稱);畫出各種圖像
imagegif(圖片資源,保存路徑);
imagepng()
imagejpeg();
二、獲取圖片屬性
imagesx(res//寬度
imagesy(res//高度
getimagesize(文件路徑)
返回一個具有四個單元的數組。索引
0 包含圖像寬度的像素值,索引 1 包含圖像高度的像素值。索引 2 是圖像類型的標記:1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 =
PSD,6 = BMP,7 = TIFF(intel byte order),8 = TIFF(motorola byte order),9 = JPC,10
= JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF,15 = WBMP,16 = XBM。這些標記與 PHP 4.3.0 新加的
IMAGETYPE 常量對應。索引 3 是文本字元串,內容為「height="yyy" width="xxx"」,可直接用於 IMG
標記。
銷毀圖像資源
imagedestroy(圖片資源);
三、透明處理
PNG、jpeg透明色都正常,只有gif不正常
imagecolortransparent(resource
image [,int
color])//將某個顏色設置成透明色
imagecolorstotal()
imagecolorforindex();
四、圖片的裁剪
imageresized()
imageresampled();
五、加水印(文字、圖片)
字元串編碼轉換string iconv ( string $in_charset ,
string $out_charset , string $str )
六、圖片旋轉
imagerotate();//制定角度的圖片翻轉
七、圖片的翻轉
沿X軸 沿Y軸翻轉
八、銳化
imagecolorsforindex()
imagecolorat()
❺ 用php代碼怎麼以背景圖片加上文字生成新的圖片,然後在標題處絕對調用該圖片
<?php
ob_clean(); //清除輸出緩存
header("Content-type:image/jpeg"); //設置輸出類型
$img="images/test.jpg"; //背景圖片名
if(isset($_GET["img"]))$img=$_GET["img"]; //也可以通過img參數傳入
$im=imagecreatefromjpeg($img); //讀入背景圖片
$text="文字內容"; //要加上的文字內容
if(isset($_GET["text"]))$text=$_GET["text"]; //也可以通過text參數傳入
$fontFile="xxx.ttf"; //字體文件名,必須要
$fontSize=36; //字體尺寸
$fontColor=ImageColorAllocate($im,0,0,0); //字體顏色,這里是黑色
$textAngle=0; //文字顯示的角度,0表示水平顯示
$textLeft=20; //文字顯示的x坐標
$textTop=60; //文字顯示的y坐標
imagefttext($im,$fontSize,$textAngle,$textLeft,$textTop,$fontColor,$fontFile,$text); //把文字覆蓋到圖片上
Imagejpeg($im); //輸出圖片
ImageDestroy($im); //銷毀圖片
?>
把以上文字保存為php文件,比如 img.php
然後在需要調用圖片的地方用 <img src="img.php?img=背景圖片文件路徑&text=要加上的文字"/> 來調用
比如 <img src="img.php?img=images/back.jpg&text=你好"/>
❻ imagettftext和imagefttext有什麼區別嗎
imagettftext — 用 TrueType 字體向圖像
imagefttext — 使用 FreeType 2 字體橡戚將文本寫入圖像梁並寫入橡如跡文本
❼ 求一個字體是大寫,字母大點的php網頁圖片驗證碼類
<?php
session_start();
vCode();
//確保用戶輸入的驗證碼等於$_SESSION["VerifyCode"] 就可以。
function vCode($num=4) {
$height=35;
$code = '';
$size=20;//字體大小
$width=$num*($size-2);
//棗飢第一個字元大寫
$str = "ABCDEFGHIJKLMNPQRSTUVW";
$code = $str[mt_rand(0, strlen($str)-1)];
//後面的字元
$str = "";
for ($i = 0; $i < $num-1; $i++) {
$code .= $str[mt_rand(0, strlen($str)-1)];
}
$_SESSION['check_auth']=$code;
// 畫圖像
$im = imagecreatetruecolor($width, $height);
// 定義要用到的顏色
$back_color = imagecolorallocate($im, 235, 236, 237);
$boer_color = imagecolorallocate($im, 118, 151, 199);
$text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
// 畫背景
imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
// 畫邊框
imagerectangle($im, 0, 0, $width-1, $height-1, $boer_color);
// 畫干擾線
for($i = 0;$i < 5;$i++) {
$font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagearc($im, mt_rand(- $width, $width), mt_rand(- $height, $height), mt_rand(30, $width * 2), mt_rand(20, $height * 2), mt_rand(0, 360), mt_rand(0, 360), $font_color);
}
// 畫干擾點
for($i = 0;$i < 50;$i++) {
$font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $font_color);
}
// 畫凳兄返驗證碼
@imagefttext($im, $size , 0, 5, $size + 3, $text_color, '../bigdata/huailiangxingshu.ttf', $code);
$_SESSION["VerifyCode"塵遲]=$code;
header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
header("Content-type: image/png;charset=utf8");
imagepng($im);
imagedestroy($im);
}
❽ imagefttext php 怎麼使用默認字體
系統是redhat linux 8.0 , 並且apache是系統預設安告斗螞裝的,可以到 /etc/httpd/conf/httpd.conf 文件里,把AddDefaultCharset 的預設字元集改成你想要的,(如:gb2312).保存文件銷滑,重起apache 就可以了襪埋。
❾ php怎麼把水印圖生成在最右下角
$dst_path = 'dst.jpg';
//創建圖片的實例
$dst = imagecreatefromstring(file_get_contents($dst_path));
//罩困打上文字
$font = './simsun.ttc';//字體
$black = imagecolorallocate($dst, 0x00, 0x00, 0x00);//字體顏色
imagefttext($dst, 13, 0, 20, 20, $black, $font, '快樂編程');
//輸出圖片
list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
switch ($dst_type) {
case 1:/櫻並/GIF
header('Content-Type: image/gif');
imagegif($dst);
break;
case 2://JPG
header('Content-Type: image/jpeg');
imagejpeg($dst);
break;
case 3://PNG
header('脊悶跡Content-Type: image/png');
imagepng($dst);
break;
default:
break;