當前位置:首頁 » 編程語言 » php出圖

php出圖

發布時間: 2023-09-06 19:58:19

『壹』 php 如何生成靜態圖片

<?php
$im = ImageCreate(200,200);$red = ImageColorAllocate($im,0xFF,0x00,0x00);
$black = ImageColorAllocate($im,0x00,0x00,0x00);
$white = ImageColorAllocate($im,0xFF,0xFF,0xFF);
$ys1 = ImageColorAllocate($im,0xE9,0xB1,0x50);
$ys2 = ImageColorAllocate($im,0x98,0x25,0xCB);
$ys3 = ImageColorAllocate($im,0x40,0x88,0x47);ImageFilledRectangle($im,50,50,150,150,$black);
//點
for($i=0;$i<300;$i++){
ImageSetPixel($im,rand(1,200),rand(1,200),$white);
}
//虛線
for($i=0;$i<10;$i++){
ImageDashedLine($im,rand(1,200),rand(1,200),rand(1,200),rand(1,200),$ys1);
}
//線
for($i=0;$i<10;$i++){
ImageLine($im,rand(1,200),rand(1,200),rand(1,200),rand(1,200),$ys1);
}
//矩形框
for($i=0;$i<3;$i++){
ImageRectangle($im,rand(1,200),rand(1,200),rand(1,200),rand(1,200),$ys1);
}
//矩形面
for($i=0;$i<2;$i++){
ImageFilledRectangle($im,rand(1,200),rand(1,200),rand(1,200),rand(1,200),$ys1);
}
//多邊形
$point = array(rand(1,200),rand(1,200),rand(1,200),rand(1,200),rand(1,200),rand(1,200));
ImagePolygon($im,$point,count($point)/2,$ys2);
ImageFilledPolygon($im,$point,count($point)/2,$ys2);
//弧線
ImageArc($im,rand(20,180),rand(20,180),rand(50,150),rand(50,150),rand(0,360),rand(0,360),$ys3);
//打字
ImageString($im,4,20,30,"add word",$ys3);
ImageTTFText($im,30,0,rand(0,50),rand(30,200),$ys3,'msyhbd.ttf',"添加文字");header('Content-Type:image/png');
ImagePNG($im);
?>

『貳』 PHP怎麼輸出一張圖片

<?php
$t=imagecreatetruecolor(100,100);
$red=imagecolorallocate($t,255,0,0);
imagefill($t,0,0,$red);
header('Content-type:image/png');
imagepng($t);
imagedestroy($t);
?>

『叄』 PHP怎麼顯示出圖片

不要用記事本直接編輯PHP文件,因為可能會存在bom頭信息,導致圖片不能正常顯示,你可以自行網路bom頭信息,建議使用編輯器notepad++,可以去除文件bom頭,圖片就會正常顯示

『肆』 php怎麼獲取文件夾內的所有圖片並且顯示出來

<?php
$dir = "./images/"; //要獲取的目錄
echo "********** 獲取目錄下所有文件和文件夾 ***********<hr/>";
//先判斷指定的路徑是不是一個文件夾
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh))!= false){
//文件名的全路徑 包含文件名
$filePath = $dir.$file;
echo "<img src='".$filePath."'/>";
}
closedir($dh);
}
}
?>

熱點內容
滑板鞋腳本視頻 發布:2025-02-02 09:48:54 瀏覽:433
群暉怎麼玩安卓模擬器 發布:2025-02-02 09:45:23 瀏覽:557
三星安卓12彩蛋怎麼玩 發布:2025-02-02 09:44:39 瀏覽:743
電腦顯示連接伺服器錯誤 發布:2025-02-02 09:24:10 瀏覽:537
瑞芯微開發板編譯 發布:2025-02-02 09:22:54 瀏覽:146
linux虛擬機用gcc編譯時顯示錯誤 發布:2025-02-02 09:14:01 瀏覽:239
java駝峰 發布:2025-02-02 09:13:26 瀏覽:652
魔獸腳本怎麼用 發布:2025-02-02 09:10:28 瀏覽:538
linuxadobe 發布:2025-02-02 09:09:43 瀏覽:212
sql2000資料庫連接 發布:2025-02-02 09:09:43 瀏覽:726