飞比寻常 (JOE) 生,简单,活,简单,生活,不简单!
JOE个人网站
JOE个人网站,不仅仅是一个网站,更像是一个展现自我的平台,致力于让朋友们都可以
有所感触,有所收获。
<?php header("content-type:text/html;charset=utf-8"); $img = imagecreate(100,50) or die('Cannot create GB image'); // 创建画布 // $img = imagecreatetruecolor(100,50); // 创建画布 $img1 = imagecreatefrompng('./png.png'); // 读取图片创建画布 $background_color = imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)); // 设置颜色 imagefill($img,0,0,$background_color); // 填充 $text_color = imagecolorallocate($img,mt_rand(0,140),mt_rand(0,140),mt_rand(0,140)); $arc_color = imagecolorallocate($img,0,0,0); $ellipse_color = imagecolorallocate($img,150,150,150); $red_color = imagecolorallocate($img,255,0,0); imagerectangle($img,0,0,99,49,$red_color); // 画矩形 for($i=0;$i<50;$i++) { imagesetpixel($img,mt_rand(0,100),mt_rand(0,50),$red_color); // 画点 } imagestring($img,5,10,20,' a b c d ',$text_color); // 写字符串 imagestringup($img,5,80,50,'efgh',$text_color); // 写竖字符串 imagearc($img,0,0,100,50,0,90,$arc_color); // 画圆 imagechar($img,3,50,0,'exe',$text_color); // 写字符 imagecharup($img,3,50,45,'xex',$text_color); // 写竖字符 imageellipse($img,50,25,80,40,$ellipse_color); // 画曲线 imagettftext($img,12,0,50,25,$text_color,'simsun.ttc','你好'); // 写文字 //imagecopy($img1,$img,0,0,0,0,100,50); // 复制图片到另一张上 imagecopymerge($img1,$img,0,0,0,0,100,50,50); // 水印 //imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // 图片缩放 //imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // 图片缩放 效果比上面好点 header("content-type:image/png"); imagepng($img1); // 输出图片 //imagejpeg($thumb,'abc1.jpg'); // 保存图片 imagedestroy($img); // 销毁画布资源 imagedestroy($img1); // 销毁画布资源 ?> # array getimagesize( string $filename [, array &$imageinfo ]) # bool imagearc( resource $image, int $cx, int $cy, int $w, int $h, int $s, int $e, int $color) # resource imagecreate( int $x_size, int $y_size) # resource imagecreatetruecolor( int $width, int $height) # resource imagecreatefromgif( string $filename) # resource imagecreatefromjpeg( string $filename) # resource imagecreatefrompng( string $filename) # int imagecolorallocate( resource $image, int $red, int $green, int $blue) # bool imagefill( resource $image, int $x, int $y, int $color) # bool imagerectangle( resource $image , int $x1, int $y1, int $x2, int $y2, int $col) # bool imagesetpixel( resource $image, int $x, int $y, int $color) # bool imagestring( resource $image, int $font, int $x, int $y, string $s, int $col) # bool imagestringup( resource $image, int $font, int $x, int $y, string $s, int $col) # bool imagearc( resource $image, int $cx, int $cy, int $w, int $h, int $s, int $e, int $color) # bool imagefilledarc( resource $image, int $cx, int $cy, int $width, int $height, int $start, int $end, int $color, int $style) # bool imagechar( resource $image, int $font, int $x, int $y, string $c, int $color) # bool imagecharup( resource $image, int $font, int $x, int $y, string $c, int $color) # bool imageellipse( resource $image, int $cx, int $cy, int $width, int $height, int $color) # bool imagecopy( resource $dst_im, resource $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h) # bool imagecopymerge( resource $dst_im, resource $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct) # array imagettftext( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text) # bool imagecopyresampled( resource $dst_image, resource $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h) # bool imagecopyresized( resource $dst_image, resource $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h) # bool imagepng( resource $image [, string $filename ]) # bool imagejpeg( resource $image [, string $filename ]) # bool imagegif( resource $image [, string $filename ]) # bool imagedestroy( resource $image)