当前位置:首页 » 编程语言 » 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-07-03 19:33:20 浏览:542
编译型语言快 发布:2025-07-03 19:31:57 浏览:410
mud服务器搭建 发布:2025-07-03 19:28:37 浏览:494
云存储空间怎么缴费 发布:2025-07-03 19:22:45 浏览:632
双机热备虚拟ip怎么配置域名 发布:2025-07-03 19:09:18 浏览:351
计算数据存储地址 发布:2025-07-03 18:48:29 浏览:713
安卓恢复出厂设置如何退出 发布:2025-07-03 18:40:41 浏览:697
家用电脑和网吧电脑做成服务器 发布:2025-07-03 18:22:07 浏览:860
jsp刷新缓存 发布:2025-07-03 18:18:06 浏览:924
机房服务器启动不起来是什么原因 发布:2025-07-03 18:18:02 浏览:447