<?php
/*
创建图片
imagecreate — 新建一个基于调色板的图像
resource imagecreate ( int $x_size , int $y_size )
imagecreatetruecolor 新建一个真彩色图像
resource imagecreatetruecolor ( int $x_size , int $y_size )
图像分配颜色
imagecolorallocate — 为一幅图像分配颜色
int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
imagecolorallocatealpha — 为一幅图像分配颜色 + alpha(透明度,1-127)
int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
bool imagecolordeallocate ( resource $image , int $color ) 取消图像颜色的分配
在图片上画东东
imageline — 画一条线段
bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
imagestring — 水平地画一行字符串
bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
imageloadfont — 载入一新字体
int imageloadfont ( string $file )
输出图像
imagepng — 以 PNG 格式将图像输出到浏览器或文件
bool imagepng ( resource $image [, string $filename ] )
imagegif(),imagewbmp(),imagejpeg() 和 imagetypes()。
销毁一图像
imagedestroy — 销毁一图像、
bool imagedestroy ( resource $image )
取得图像大小
array getimagesize ( string $filename [, array &$imageinfo ] )
eg:getimagesize("img/flag.jpg"); getimagesize("http://www.example.com/gifs/logo.gif");
int imagesx ( resource $image ) - 取得图像宽度
int imagesy ( resource $image ) — 取得图像高度
*/
// 建立一幅图像 大小:100X30
//$im = imagecreatefrompng('bg.png');
$im = imagecreate(100, 30);
// 填充背景 白色背景和蓝色文本
$bg = imagecolorallocate($im, 155, 155, 155);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// 把字符串写在图像左上角
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);
// 输出图像
header("Content-type: image/png");
imagepng($im);
php图像处理
最新推荐文章于 2025-08-17 22:31:15 发布