?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<?php
header( "content-type" , "text/html;charset=utf-8" );
/*扇形统计图*/
$image = imagecreatetruecolor(100, 100); /*创建画布*/
/*设置画布需要的颜色*/
$white = imagecolorallocate( $image ,0xff,0xff,0xff);
$gray = imagecolorallocate( $image , 0xc0, 0xc0, 0xc0);
$darkgray = imagecolorallocate( $image , 0x90, 0x90, 0x90);
$navy = imagecolorallocate( $image , 0x00, 0x00, 0x80);
$darknavy = imagecolorallocate( $image , 0x00, 0x00, 0x50);
$red = imagecolorallocate( $image , 0xff, 0x00, 0x00);
$darkred = imagecolorallocate( $image , 0x90, 0x00, 0x00);
/*填充背景色*/
imagefill( $image , 0, 0, $white );
/*3D制作*/
for ( $i = 60; $i > 50; $i --)
{
imagefilledarc( $image , 50, $i , 100, 50, -160, 40, $darknavy , IMG_ARC_PIE);
imagefilledarc( $image , 50, $i , 100, 50, 40, 75, $darkgray , IMG_ARC_PIE);
imagefilledarc( $image , 50, $i , 100, 50, 75, 200, $darkred , IMG_ARC_PIE);
}
/*画椭圆弧并填充*/
imagefilledarc( $image , 50, 50, 100, 50, -160, 40, $darknavy , IMG_ARC_PIE);
imagefilledarc( $image , 50, 50, 100, 50, 40, 75, $darkgray , IMG_ARC_PIE);
imagefilledarc( $image , 50, 50, 100, 50, 75, 200, $darkred , IMG_ARC_PIE);
/*画字符串*/
imagestring( $image , 3, 15, 55, "30%" , $white );
imagestring( $image , 3, 45, 35, "60%" , $white );
imagestring( $image , 3, 60, 60, "10%" , $white );
/*输出图像*/
header( "content-type:image/png" );
imagepng( $image );
/*释放资源*/
imagedestroy( $image );
?>
|
效果:
2、对图片进行缩放
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<div>
<h4>原图大小</h4>
<img src= "1.png" style= "border:1px solid red;" >
</div>
<?php
header( "content-type" , "text/html;charset=utf-8" );
/*
*图片缩放
*@param string $filename 图片的url
*@param int $width 设置图片缩放的最大宽度
*@param int $height 设置图片缩放的最大高度
*/
function thumb( $filename , $width =130, $height =130)
{
/*获取原图的大小*/
list( $width_orig , $height_orig ) = getimagesize ( $filename );
/*根据参数$width和$height,换算出等比例的高度和宽度*/
if ( $width && ( $width_orig < $height_orig ))
{
$width = ( $height / $height_orig ) * $width_orig ;
}
else
{
$height = ( $width / $width_orig ) * $height_orig ;
}
/*以新的大小创建画布*/
$image_p = imagecreatetruecolor( $width , $height );
/*获取图像资源*/
$image = imagecreatefrompng( $filename );
/*使用imagecopyresampled缩放*/
imagecopyresampled( $image_p , $image , 0, 0, 0, 0, $width , $height , $width_orig , $height_orig );
/*保存缩放后的图片和命名*/
imagepng( $image_p , 'test.png' );
/*释放资源*/
imagedestroy( $image_p );
imagedestroy( $image );
}
/*调用函数*/
thumb( '1.png' );
?>
<div>
<h4>缩放后的大小</h4>
<img src= "test.png" style= "border:1px solid red;" >
</div>
|
效果:
相关文章
猜你喜欢
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
- 个人网站搭建:如何挑选具有弹性扩展能力的服务器? 2025-06-10
- 个人服务器网站搭建:如何选择适合自己的建站程序或框架? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-06-04 49
-
2025-05-25 22
-
2025-05-29 19
-
MyBatisCodeHelper-Pro插件破解版详细教程[2.8.2]
2025-05-29 39 -
2025-05-29 78
热门评论