<?php
//getimagesize - 取得图片的大小[即长与宽]
//print_r(getimagesize("./logo_i.gif"));
//Array ( [0] => 240 [1] => 124 [2] => 1 [3] => width="240" height="124" [bits] => 8 [channels] => 3 [mime] => image/gif ) //image_type_to_mime_type - 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的图像类型的 MIME 类型
//$aa = getimagesize("./logo_i.gif");
//print_r(image_type_to_mime_type ($aa)); //imagearc — 画椭圆弧
/*bool imagearc(resource $image ,int $cx ,int $cy ,int $w ,int $h , int $s , int $e , int $color);
//$image:资源
//$cx:左边离圆心的位置
//$cy:上边离圆心的位置
//$w:圆形的直径左右
//$h:圆形的直径上下
//$s:0度顺时针画
//$e:360
//$color:圆形的颜色
// 创建一个 200X200 的图像
$img = imagecreatetruecolor(200, 200);
// 分配颜色
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);
// 画一个白色的圆
imagearc($img, 100, 100, 150, 150, 0, 360, $white);
// 将图像输出到浏览器
header("Content-type: image/png");
imagepng($img);
// 释放内存
imagedestroy($img);*/ //imagechar — 水平地画一个字符
/*bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color )
$image:资源
$font:字体大小
$x:文字离左边框的距离
$y:文字离上边框的距离
$c:将字符串 c 的第一个字符画在 image 指定的图像中
$color:文字的颜色
$im = imagecreate(100,100);
$string = 'php';
$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// prints a black "P" in the top left corner
imagechar($im, 1, 0, 0, $string, $black);
header('Content-type: image/png');
imagepng($im);*/ //imagecharup — 垂直地画一个字符
/*bool imagecharup ( resource $image , int $font , int $x , int $y , string $c , int $color )
$image:资源
$font:字体大小
$x:文字离左边框的距离
$y:文字离上边框的距离
$c:将字符串 c 的第一个字符画在 image 指定的图像中
$color:文字的颜色
$im = imagecreate(100,100);
$string = 'Note that the first letter is a N';
$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// prints a black "Z" on a white background
imagecharup($im, 3, 10, 10, $string, $black);
header('Content-type: image/png');
imagepng($im);
*/ //imagecolorallocate — 为一幅图像分配颜色
/*int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
$image:图片资源
$red,$green,$blue分别是所需要的颜色的红,绿,蓝成分。这些参数是 0 到 255 的整数或者十六进制的 0x00 到 0xFF
第一次对 imagecolorallocate() 的调用会给基于调色板的图像填充背景色
$im = imagecreate( 100, 100);
// 背景设为红色
$background = imagecolorallocate($im, 255, 0, 0);
// 设定一些颜色
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// 十六进制方式
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
header('Content-type: image/png');
imagepng($im);
*/ //imagecolorallocatealpha — 为一幅图像分配颜色 + alpha
/*int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
imagecolorallocatealpha() 的行为和 imagecolorallocate() 相同,但多了一个额外的透明度参数 alpha,其值从 0 到 127。0 表示完全不透明,127 表示完全透明。
$size = 300;
$image=imagecreatetruecolor($size, $size);
// 用白色背景加黑色边框画个方框
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
imagerectangle($image, 0, 0, $size - 1, $size - 1, $border);
$yellow_x = 100;
$yellow_y = 75;
$red_x = 120;
$red_y = 165;
$blue_x = 187;
$blue_y = 125;
$radius = 150;
// 用 alpha 值分配一些颜色
$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75);
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
// 画三个交迭的圆
imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow);
imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red);
imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue);
// 不要忘记输出正确的 header!
header('Content-type: image/png');
// 最后输出结果
imagepng($image);
imagedestroy($image);
*/ //imagecolordeallocate — 取消图像颜色的分配
/*bool imagecolordeallocate ( resource $image , int $color )
imagecolordeallocate() 函数取消先前由 imagecolorallocate() 或 imagecolorallocatealpha() 分配的颜色。
$im = imagecreate( 100, 100);
// 背景设为红色
$background = imagecolorallocate($im, 255, 0, 0);
// 设定一些颜色
$white = imagecolorallocate($im, 255, 255, 255);
imagecolordeallocate($im,$white);
header('Content-type: image/png');
imagepng($im);*/ //imagecolorexact — 取得指定颜色的索引值
/*int imagecolorexact ( resource $image , int $red , int $green , int $blue )
返回图像调色板中指定颜色的索引值。
如果颜色不在图像的调色板中,返回 -1。
如果从文件创建了图像,只有图像中使用了的颜色会被辨析。仅出现在调色板中的颜色不会被辨析。
$im = imagecreate( 100, 100);
// 背景设为红色
$background = imagecolorallocate($im, 255, 0, 0);
// 设定一些颜色
$white = imagecolorallocate($im, 255, 255, 255);
$aa = imagecolorexact ($im, 255, 0, 0);
echo $aa; //不存在返回-1*/ //imagecolorset — 给指定调色板索引设定颜色
/*void imagecolorset ( resource $image , int $index , int $red , int $green , int $blue )
本函数将调色板中指定的索引设定为指定的颜色。
$im = imagecreate( 100, 100);
$background = imagecolorallocate($im, 255, 0, 0);
for($c = 0;$c<50;$c++){
imagecolorset($im,$c,255,255,255 );
}
header('Content-type: image/png');
imagepng($im);*/ //imagecolortransparent — 将某个颜色定义为透明色
/*int imagecolortransparent ( resource $image [, int $color ] )
imagecolortransparent() 将 image 图像中的透明色设定为 color。image 是 imagecreatetruecolor() 返回的图像标识符,color 是 imagecolorallocate() 返回的颜色标识符。
$im = imagecreate(100,100);
$background = imagecolorallocate($im, 0, 0, 0);
imagecolortransparent ($im,$background);
header('Content-type: image/png');
imagepng($im);*/ ?>

php-GD库的函数(一)的更多相关文章

  1. GD库常用函数

    创建句柄 imagecreate($width, $height)                                                  //新建图像 imagecreat ...

  2. PHP的GD库

    GD库 PHP通过GD库,可以对JPG.PNG.GIF.SWF等图片进行处理.GD库常用在图片加水印,验证码生成等方面. 绘制线条 要对图形进行操作,首先要新建一个画布,通过imagecreatetr ...

  3. gd库

    1.开启GD库扩展 去掉注释: extension=php_gd2.dll extension_dir='ext目录所在位置' 2.检测GD库是否开启 phpinfo(); //检测扩展是够开启 ex ...

  4. GD库处理图像

    在PHP5中,动态图象的处理要比以前容易得多.PHP5在php.ini文件中包含了GD扩展包,只需去掉GD扩展包的相应注释就可以正常使用了.PHP5包含的GD库正是升级的GD2库,其中包含支持真彩图像 ...

  5. PHP->利用GD库新建图像

    1.确认php中GD库是否开启 在PHP配置文件php.ini中查找extension=php_gd2.dll,去掉前边的(分号) ';' 即可,一般php是默认开启的 2.绘画步骤 创建一个画布(画 ...

  6. php中GD库的简单使用

    在php中需要图像处理的地方GD库会发挥重要的作用,php可以创建并处理包括GIF,PNG,JPEG,WBMP以及XPM在内的多种图像格式,简单的举几个例子: 1.用GD库会创建一块空白图片,然后绘制 ...

  7. 安装GD库解决ThinkPHP 验证码Call to undefined function Think\imagecreate()出错

    在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会提示 ...

  8. PHP图形图像处理之初识GD库

    d=====( ̄▽ ̄*)b 引语 php不仅仅局限于html的输出,还可以创建和操作各种各样的图像文件,如GIF.PNG.JPEG.WBMP.XBM等. php还可以将图像流直接显示在浏览器中. 要处 ...

  9. 解决PHP开启gd库无效的问题

    最近需要重新安装PHP,以前一直使用的都是XAMPP,基本上都不需要自己配置,现在准备直接下载官方原版的Apache和PHP,自己来慢慢摸索如何继承配置. 我下载的Apache版本为2.2.25,PH ...

  10. GD库使用小结---2

    接着上一篇.GD库可以折腾很多用法出来,当然得跟画图相关,除了前面的验证码.水印外,还可以进行图片的缩放,裁剪.旋转等操作,这在很多应用中可以见到. 1. 加水印 前面已经知道,我们可以使用image ...

随机推荐

  1. MYSQL truncate table

    准备: 要说truncate table 就要先说一下delete 它们两个都可以用来从表中删除数据行!表面上看是delete 删除的慢一些,truncate table 快一些. delete : ...

  2. Sql Server专题:SQL 经典实例

    SQL 经典实例 1.实例表: Student(S#,Sname,Sage,Ssex) 学生表 S#:学号:Sname:学生姓名:Sage:学生年龄:Ssex:学生性别 Course(C#,Cname ...

  3. apache端口被占用

      1.80端口被占用,先去服务里将IIS关闭掉,然后重启apache,如果还是继续弹窗the requested operation has failed...需要去Internet信息服务里面停止 ...

  4. Connect the Cities(prime)

    Connect the Cities Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) ...

  5. SVN连接不上

    某次我们部门换了场地.SVNserver就连接不上了,后来公司数据中心处理好后,还是连接不上,原来还需刷新自己电脑的DNS. 如需转载,请注明出处http://blog.csdn.net/combat ...

  6. 设计师Yoyo:为用户设计产品,让他们生活更美好

    Yoyo设计走过的路:纽约爱立信,西雅图美国在线,硅谷雅虎,ATT,深圳腾讯,华为:Yoyo不仅是顶级的交互体验设计师,还是很Open的知识分享者,从职业选择,以及对年轻人的建议几个角度,摘录他的文章 ...

  7. 【机房系统知识小结点系列】之遍历窗体中的控件,判断Text是否为空?

    做机房系统时,几乎每个窗体中都会用到判断界面中的控件是否为空的情景.我们曾经是这样走来的: 第一版: 好处:对窗体界面中的Text等控件,逐一做判断,当用户输入某一项为空的时候,会议弹出框的形式,告诉 ...

  8. VS2010中查询替换使用

    MSDN:http://msdn.microsoft.com/zh-cn/library/afy96z92.aspx 例子:

  9. Oracle的分页查询语句优化

    Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用. (一)   分页查询格式: SELECT * FROM  ( SELECT A.*, ROWNUM RN  FROM (SELECT ...

  10. VB.NET 初涉线程的定义和调用

    什么是线程 说话一:进程是具有一定独立功能的程序关于某个数据集合上的一次运行活动,进程是系统进行资源分配和调度的一个独立单位. 线程是进程的一个实体,是CPU调度和分派的基本单位,它是比进程更小的能独 ...