<?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. C++ 前置声明 和 包含头文件 如何选择

    假设有一个Date类 Date.h class Date { private: int year, month, day; }; 如果有个Task类的定义要用到Date类,有两种写法 其一 Task1 ...

  2. FastReport.net 使用记录

    FastReport.net  打印设计功能非常强大,打印内容可以自己设计.数据源可以来至许多个表,打印设计后的表格数据是以二进制保存在数据库中的. 1.打印设计: private void Desi ...

  3. Jquery基础之动画操作

    Jquery的动画效果能够轻松的为网页添加动画效果,为网页带来了新的活力. 一.show()方法和hide()方法 show()方法和hide()方法是jquery中最基本的动画方法.使用show() ...

  4. Qt 鼠标样式特效探索样例(一)——利用时间器调用QWidget.move()函数

    Qt 鼠标样式特效探索样例(一)       心血来潮,突然想在Qt里玩一把鼠标样式,想到在浏览网页时,经常看到漂亮的鼠标动画,于是今天摸索着乱写个粗糙的demo,来满足自己的好奇心. 效果图 方案要 ...

  5. HDU 2517 / POJ 1191 棋盘分割 区间DP / 记忆化搜索

    题目链接: 黑书 P116 HDU 2157 棋盘分割 POJ 1191 棋盘分割 分析:  枚举所有可能的切割方法. 但如果用递归的方法要加上记忆搜索, 不能会超时... 代码: #include& ...

  6. make的命令行选项

    make的命令行选项 -b -m 忽略,提供其它版本make兼容性. -B --always-make 强制重建所有规则的目标,不根据规则的依赖描述决定是否重建目标文件. -C DIR --direc ...

  7. docker学习笔记(1)

    (1)Docker介绍 关于Docker的介绍,我就不列举出来了.到百度.谷歌搜索.非常多介绍文章.以下我给出官网的介绍:https://www.docker.com/whatisdocker/ (2 ...

  8. rem和em和px vh vw和% 移动端长度单位

    1.rem和em.px 首先来说说em和px的关系 em是指字体高度 浏览器默认1em=16px,所以0.75em=12px;我们经常会在页面上看到根元素写的font-size:65%; 这样em就成 ...

  9. web中通过注释判断浏览器<!--[if !IE]><!--[if IE]><!--[if lt IE 6]><!--[if gte IE 6]>版本

    <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--><!--[if IE]> 所有的IE可识别 <![e ...

  10. easyui combo自动高度(下拉框空白问题)

    设置.combo-panel {max-height:200px;} 在用到easyui-combobox时,设置panelHeight:'auto'