php 创建图像实例

 更新时间:2016年11月25日 16:57  点击:2100
使用ImageCreate()创建一个代表空白图像的变量,这个函数要求以像素为单位的图像大小的参数,其格式是ImageCreate(x_size, y_size)。如果要创建一个大小为250×250的图像,就可以使用下面的语句:   

<? header ("content-type: image/png");  

   

 代码如下 复制代码
  $newimg = imagecreate(250,250);  

 

  由于图像还是空白的,因此你可能会希望用一些彩色来填充它。你需要首先使用imagecolorallocate()函数用其rgb值为这种颜色指定一个名字,这一函数的格式为imagecolorallocate([image], [red], [green], [blue])。如果要定义天蓝色,可以使用如下的语句:  

 

 代码如下 复制代码
  $skyblue = imagecolorallocate($newimg,136,193,255);  

 

  接下来,需要使用imagefill()函数用这种颜色填充这个图像,imagefill()函数有几个版本,例如imagefillrectangle()、imagefillpolygon()等。为简单起见,我们通过如下的格式使用imagefill()函数:  

 代码如下 复制代码

  imagefill([image], [start x point], [start y point], [color])

  imagefill($newimg,0,0,$skyblue);  

 

  最后,在图像建立后释放图像句柄和所占用的内存:  

 

 代码如下 复制代码

 imagepng($newimg);

  imagedestroy($newimg); ?>

  这样,创建图像的全部代码如下所示:

      php教程代码:
 

 代码如下 复制代码

<? header ("content-type: image/png");

  $newimg = imagecreate(250,250);

  $skyblue = imagecolorallocate($newimg,136,193,255);

  imagefill($newimg,0,0,$skyblue);

  imagepng($newimg);

  imagedestroy($newimg);

  ?>   

在php中要生成中文验证码就必须做与生成验证验证码不一样的操作,因为GD函数只接受UTF8格式编码的文字,所以在用php生成中文验证码时面要前首先要进行编码转换,操作php的iconv可以实例。
 代码如下 复制代码

$ch_str="你要生成中文验证码汉字";
$str=array();
for ($i=0;$i<strlen($ch_str);$i+=3)
{
    $str[]=$ch_str[$i].$ch_str[$i+1].$ch_str[$i+2];
}
//图片的长和高
$image_x=200;
$image_y=100;
$im = imagecreate($image_x,$image_y);
//这里取图片底色为白色
$bkg = imagecolorallocate($im,255,255,255);
//显示的字体样式,这个要把文件放到对应的目录中,如果你没有文件就去window的字体文件中找一个吧。
$fnt = "simfang.ttf";
//为图像分配一些颜色
$white=imagecolorallocate($im,234,185,95);
//在图片上画椭圆弧,指定下坐标点
imagearc($im, 150, 8, 20, 20, 75, 170, $white);
imagearc($im, 180, 7,50, 30, 75, 175, $white);
//在图片上画一条线段,指定下坐标点
imageline($im,20,20,180,30,$white);
imageline($im,20,18,170,50,$white);
imageline($im,25,50,80,50,$white);
//乱点的数量
$noise_num=3000;
$line_num=80;
//各种混乱字符的颜色
$rectangle_color=imagecolorallocate($im,0xaa,0xaa,0xaa);
$noise_color=imagecolorallocate($im,0x00,0x00,0x00);
$font_color=imagecolorallocate($im,0x00,0x00,0x00);
for($i=0;$i<$noise_num;$i++)
{
    //在一个坐标点上画一个单一像素,这个点上面定义了,是黑色的。
    imagesetpixel($im,mt_rand(0,$image_x),mt_rand(0,$image_y),$noise_color);
}

for($i=0;$i<$line_num;$i++)
{
    $line_color=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
    //在两个坐标点间画一条线,颜色在上面定义
    imageline($im,mt_rand(0,$image_x),mt_rand(0,$image_y),mt_rand(0,$image_x),mt_rand(0,$image_y),$line_color);   
}
$randnum=rand(0,count($str)-4);
//保持是偶数
if ($randnum%2)
{
    $randnum+=1;   
}
$str1=$str[$randnum].$str[$randnum+1];
for ($i=0;$i<2;$i++)
{
    imagettftext($im, rand(28,32), rand(0,70), rand(($image_x/4)*$i+$image_x/10,($image_x/4)*$i+$image_x/8), rand($image_y/2+$image_y/10,$image_y/2+$image_y/5), $font_color, $fnt, $str[$randnum+$i]);   
}
imagepng($im);
imagedestroy($im);

//生成中文验证码二
$str="中文汉字";
$image_x=110;
$image_y=110;
$im = imagecreate($image_x,$image_y);
$bkg = imagecolorallocate($im,255,255,255);
$fnt = "hb.ttf"; //显示的字体样式
$white=imagecolorallocate($im,234,185,95);
imagearc($im, 150, 8, 20, 20, 75, 170, $white);
imagearc($im, 180, 7,50, 30, 75, 175, $white);
imageline($im,20,20,180,30,$white);
imageline($im,20,18,170,50,$white);
imageline($im,25,50,80,50,$white);
$noise_num=3000;
$line_num=80;
imagecolorallocate($im,0xff,0xff,0xff);
$rectangle_color=imagecolorallocate($im,0xaa,0xaa,0xaa);
$noise_color=imagecolorallocate($im,0x00,0x00,0x00);
$font_color=imagecolorallocate($im,0x00,0x00,0x00);
$line_color=imagecolorallocate($im,0x00,0x00,0x00);
for($i=0;$i<$noise_num;$i++)
imagesetpixel($im,mt_rand(0,$image_x),mt_rand(0,$image_y),$noise_color);
for($i=0;$i<$line_num;$i++)
imageline($im,mt_rand(0,$image_x),mt_rand(0,$image_y),mt_rand(0,$image_x),mt_rand(0,$image_y),$line_color);
$randnum=rand(0,strlen($str)-4);
if ($randnum%2)$randnum+=1;
$str1=substr($str,$randnum,4);
$str2 = iconv("gb2312","utf-8",$str1);//验证汉字在$str1里面

imagettftext($im, rand(28,32), rand(0,70), rand(25,27), rand(70,100), $font_color, $fnt, $str2);
imagepng($im);
imagedestroy($im);

//把汉字放在数组
/*
gd函数只接受utf8格式编码的文字,所以在写文字前首先要进行编码转换。php自带的iconv和mbstring库都可以完成这项工作
*/

$randcode=array('宠');
$codetable=array();
$fp=fopen("gb2312.txt","r");
while($line=fgets($fp))
    $codetable[hexdec(substr($line,0,6))]=substr($line,7,6);
fclose($fp); 

//gb2312转utf8
function gb2utf8($gbstr)
{
    global $codetable;
    if(trim($gbstr)=="")
        return $gbstr;
    $ret="";
    $utf8="";
    while($gbstr)
    {
        if(ord(substr($gbstr,0,1))>127)
        {
            $thisw=substr($gbstr,0,2);
            $gbstr=substr($gbstr,2,strlen($gbstr));
            $utf8="";
            @$utf8=u2utf8(hexdec($codetable[hexdec(bin2hex($thisw))-0x8080]));

 

            if($utf8!="")
            for($i=0;$i<strlen($utf8);$i+=3)
                $ret.=chr(substr($utf8,$i,3));
        }
        else
        {
            $ret.=substr($gbstr,0,1);
            $gbstr=substr($gbstr,1,strlen($gbstr));
        }
    }
    return $ret;

 

//unicode转utf8
function u2utf8($c)
{
    $str="";
    if($c<0x80)
        $str.=$c;
    elseif($c<0x800)
    {
        $str.=(0xc0|$c>>6);
        $str.=(0x80|$c&0x3f);
    }
    elseif($c<0x10000)
    {
        $str.=(0xe0|$c>>12);
        $str.=(0x80|$c>>6&0x3f);
        $str.=(0x80|$c&0x3f);
    }
    elseif($c<0x200000)
    {
        $str.=(0xf0|$c>>18);
        $str.=(0x80|$c>>12&0x3f);

 

        $str.=(0x80|$c>>6&0x3f);
        $str.=(0x80|$c&0x3f);
    }
    return $str;

//生成附加码
function create_excode($length)
{
 global $randcode;
    header("content-type: image/png");
 $image_x=$length*30;    //图片宽度
 $image_y=40;            //图片高度
    $noise_num=80*$length;   //杂点数量
    $line_num=$length-2;      //干扰线数量
 $image=imagecreate($image_x,$image_y);
 imagecolorallocate($image,0xff,0xff,0xff);                  //设定背景颜色
 $rectangle_color=imagecolorallocate($image,0xaa,0xaa,0xaa); //边框颜色
 $noise_color=imagecolorallocate($image,0x00,0x00,0x00);     //杂点颜色
 $font_color=imagecolorallocate($image,0x00,0x00,0x00);      //字体颜色
 $line_color=imagecolorallocate($image,0x33,0x33,0x33);      //干扰线颜色

 //加入杂点
    for($i=0;$i<$noise_num;$i++)
  imagesetpixel($image,mt_rand(0,$image_x),mt_rand(0,$image_y),$noise_color);

 $font_face="simkai.ttf";    //字体
    $x=2;
    $session_code='';
    for($i=0;$i<$length;$i++)
    {
        $code=$randcode[mt_rand(0,count($randcode)-1)];
     imagettftext($image,18,mt_rand(-6,6),$x,29,$font_color,$font_face,gb2utf8($code));
        $x+=30;
        $session_code.=$code;
    }
    @session_start();
    $_session['excode']=$session_code;  //把附加码的值放在session中

 
    //加入干扰线
    for($i=0;$i<$line_num;$i++)
     imageline($image,mt_rand(0,$image_x),mt_rand(0,$image_y),
                    mt_rand(0,$image_x),mt_rand(0,$image_y),$line_color);
 imagerectangle($image,0,0,$image_x-1,$image_y-1,$rectangle_color);  //加个边框
 imagepng($image);
 imagedestroy($image);
}
create_excode(6);

 

// 使用的时候直接用html语法:<img src="excode.php">调用就可以了,在服务端做验证时取session存储的验证字符与用户提交的字符进行比较,相同则通过验证

 代码如下 复制代码

<?php教程

/**
 *  ecshop jpgraph图表类库
 *  ==============================================================
 *  利用开源的jpgraph库实现对各类型数据以图表,走势图的形式表现出来。
 *  ==============================================================
**/

class cls_jpgraph
{
 var $db = null;
 var $ydata = array();
 var $width = 350;
 var $height = 250;

 var $graph = ''; //图形对象
 var $piegraph = ''; //丙状图形

 var $lineplot = ''; //线性对象
 var $barpot = ''; //柱状对象
 var $gbplat = ''; //柱状组对象
 var $txt = '';  //文本对象
 var $p1 = '';  //丙状图对象

 var $scale = ''; //图表类型? (textlin,textlog,intlin)
 var $yscale = '';   // (log,)
 var $xgrid = false; //x轴网格显示
 var $ygrid = false; //y轴网格显示
 var $title = ''; //标题
 var $subtitle = ''; //子标题(一般为日期)
 var $xaxis = ''; //x轴名称
 var $yaxis = ''; //y轴名称

 /*margin position*/
 var $left = 0;
 var $right = 0;
 var $top = 0;
 var $bottom = 0;

 /**
 *构造函数
 */
 function cls_jpgraph($width=350,$height=250)
 {
  $this->width = $width;
  $this->height = $height;

  $this->graph = new graph($this->width,$this->height);

 }

 /**
 * 图表类库的构造函数
 *
 */
 /*
 function __construct($parms,$width,$height)
 {
  cls_jpgraph($parms,$width,$height);
 }
 */

 /*图片基本信息设置*/
 function set_jpgraph($scale='intlin',$title='',$subtitle='',$bgcolor='',$xaxis='',
               $yaxis='',$xgrid=false,$ygrid=false,$margin='') {

  $this->scale = $scale;
  $this->title = $title;
  $this->subtitle = $subtitle;
  $this->xaxis = $xaxis;
  $this->yaxis = $yaxis;
  $this->xgrid = $xgrid;
  $this->ygrid = $ygrid;

  if(!empty($scale)) {
   $this->graph->setscale($this->scale);
  }
  else {
  $this->graph->setscale('intlin');
  }
  $this->graph->xgrid->show($this->xgrid,$this->xgrid);
  $this->graph->ygrid->show($this->ygrid,$this->ygrid);

  if(!empty($bgcolor)) {
   $this->graph->setmargincolor($bgcolor);
  }

  /*如果手工设置了图片位置*/
  if(is_array($margin)) {
   while(list($key,$val) = each($margin)) {
    $this->$key = $val;
   }
   $this->graph->setmargin($this->left,$this->right,$this->top,$this->bottom);
  }

  if(!empty($this->title)) {
   $this->graph->title->set($this->title);
  }
  if(!empty($this->subtitle)) {
   $this->graph->subtitle->set($this->subtitle);
  }
  else {
   $this->graph->subtitle->set('('.date('y-m-d').')'); //默认子标题设置为当前日期
  }
  if(!empty($this->xaxis)) {
   $this->graph->xaxis->title->set($this->xaxis);
  }
  if(!empty($this->yaxis)) {
   $this->graph->yaxis->title->set($this->yaxis);
  }

 }

 /*创建线性关系图表(linear plot)*/
 function create_lineplot($parms,$color='black',$weight=1)
 {
  $this->ydata = $parms;
  $this->lineplot = new lineplot($this->ydata);
  $this->lineplot->setcolor($color);
  $this->lineplot->setweight($weight);

  return $this->lineplot;
 }

 /*创建柱状图表(bar pot)*/
 function create_barpot($parms,$color='black',$width='0')
 {
  $this->ydata = $parms;
  $this->barpot = new barplot($this->ydata);
  $this->barpot->setfillcolor($color);
  if(!empty($width)) {
   $this->barpot->setwidth($width);
  }

  return $this->barpot;
 }

 /*创建数据柱状图表组*/
 function create_bargroup($plotarr,$width='0.8')
 {
  $this->gbplot = new groupbarplot($plotarr);
  $this->gbplot->setwidth($width);

  return $this->gbplot;
 }

 /*创建文本内容*/
 function create_text($str,$postion='',$color='black')
 {
  $this->txt = new text($str);

  if(is_array($postion)) {
   while(list($key,$val) = each($postion)) {
    $this->$key = $val;
   }
   $this->txt->setpos($this->left,$this->top);
  }
  else {
   $this->txt->setpos(10,20);
  }
  $this->txt->setcolor($color);

  $this->graph->add($this->txt);
 }

 /*创建丙状图表*/
 function create_pie($parms,$title,$type='3d',$size='0.5',$center='0.5',$width='350',$height='250')
 {
  $this->width = $width;
  $this->height = $height;

  $this->piegraph = new piegraph(300,200);
  $this->piegraph->setshadow();

  $this->piegraph->title->set($title);

  if('3d' != $type) {
   $this->p1 = new pieplot($parms);
   $this->piegraph->add($this->p1);
  }
  else {
   $this->p1 = new pieplot3d($parms);
   $this->p1->setsize($size);
   $this->p1->setcenter($center);
//   $this->p1->setlegends($gdatelocale->getshortmonth());
   $this->piegraph->add($this->p1);
  }
  $this->piegraph->stroke();
 }

 function get_auth_code($length=4)
 {
  $spam = new antispam();
  $chars = $spam->rand($length);

  if( $spam->stroke() === false ) {
   return false;
  }

  return $chars;
 }

 /*完成图形创建并显示*/
 function display($obj)
 {
  $this->graph->add($obj);
  $this->graph->stroke();
 }
}

?>

.jpgraph开源项目介绍
jpgraph是一个面向对象图形创建函数库。可用它来生成柱状图,饼状图,甘特图,网状图等常用到的一些图形。支持的图片格式有gif,jpg和png。

jpgraph是一个开源的利用php教程编写的专门提供图表的类库。它使得作图变成了一件非常简单的事情,你只需从数据库教程中取出相关数据,定义标题,图表类型等内容,你只需要学习掌握为数不多的jpgraph内置函数(可以参照jpgraph附带例子学习),利用简单的几行代码就可以做出超酷超炫的图表来!

2.jpgraph下载安装及使用
jpgraph的官方下载地址是:http://jpgraph.net/download/

下载时要注意,jpgraph分为几个版本,你可以根据你的php版本来确定下载那个版本的jpgraph库文件。

安装的话比较简单,不过需要注意下面两点:

确保你的php版本最低为4.04(不过我估计一般现在都5.0以上了,应该不成问题)。
另外一定要支持gd库,jpgraph是基于gd库的,至于gd库版本则可随意。
下载完成jpgraph后,将压缩包解压到任意目录下,进入到jpgraph-版本号目录下,有两个目录,其他的txt文件为简单使用说明文件,可以看看了解即可。docportal目录为帮助系统目录,其中包括从开始安装配置到使用说明,函数介绍等一应俱全,如果有耐心的话,可以好好看看。

我们主要需要的examples目录,在它里面包含了jpgraph库文件和很多的样例文件,我们可以查看学习它的样例文件,这样学习使用起来jpgraph才是最快的。

在jpgraph库文件目录中有一个名为jpg-config.inc的文件,它是jpgraph的配置文件,通过这里可以设置jpgraph的相关参数,例如设置jpgraph的cache(缓存)文件夹,和ttf(字体)文件夹等内容。

注意事项:

cache(缓存)文件夹路径可以自己定义,而ttf(字体)文件夹必须是%system%/fonts。
确保php对cache(缓存)文件夹有写的权限。
注意程序编码为utf-8编码。
3.简单样例
关于jpgraph的样例程序在examples目录下实在够多,我就不再过多罗嗦,就简单说明一下写法及上一个小例子。

首先在程序开始引用包含jpgraph库文件:

require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
然后开始创建图形对象:

$graph = new graph(350,250);
设置图形及图表的各种样式属性参数:

$graph->setscale("textlin");
$graph->img->setmargin(30,90,40,50);
$graph->xaxis->setfont(ff_font1,fs_bold);
最后进行显示:

$graph->add($lineplot);
$graph->stroke();
下面是一个比较简单的但完整的jpgraph程序样例:

setscale("textlin");
$graph->img->setmargin(30,90,40,50);
$graph->xaxis->setfont(ff_font1,fs_bold);
$graph->title->set("dashed lineplot");

// create the linear plot
$lineplot=new lineplot($ydata);
$lineplot->setlegend("test 1");
$lineplot->setcolor("blue");

// style can also be specified as setstyle([1|2|3|4]) or
// setstyle("solid"|"dotted"|"dashed"|"lobgdashed")
$lineplot->setstyle("dashed");

// add the plot to the graph
$graph->add($lineplot);

// display the graph
$graph->stroke();
?>
到此jpgraph库的基本介绍就结束了,再下一篇我会放出我写的已经封装了jpgraph库的类文件,同时可能会有一篇关于jpgraph常见问题总结的说明,欢迎大家到时候给我提出意见哦。

本教程是一款php图片上传然后,把上传的图片生成小图片哦,是一款非常好的文件上传类,如果你正在找类程序可以进来看看
 代码如下 复制代码

function uploadimage($upname,$smallmark=1,$dstsw,$dstsh=0,$path_dim,$path_xim,$newname,$smallname=0,$filetype="null") {
    global $webaddr,$_files,$my;
    $phpv=str_replace('.', '', php_version);
    $filename=$upname;
    $max_file_size = 2147483648;        //上传文件大小限制, 单位byte 2m
    $path_im = $path_dim;               //生成大图保存文件夹路径
    $path_sim = $path_xim;              //缩略图保存文件夹路径
    $simclearly=75;
    $simclearlypng =$phpv>=512?7:75;        //缩略图清晰度0-100,数字越大越清晰,文件尺寸越大
    $smallmark = $smallmark;            //是否生成缩略图(1为加生成,其他为不);
    $dst_sw =$dstsw;                   //定义缩略图宽度,高度我采用等比例缩放,所以只要比较宽度就可以了
    $uptypes=array(
        'image/jpg',
        'image/jpeg',
        'image/png',
        'image/pjpeg',
        'image/gif',
        'image/bmp',
        'image/x-png'
    );

    if (!is_uploaded_file($_files[$filename][tmp_name])) {
        dsetcookie('setok','upload1');
        header("location:111cn.net/profile");
        exit;
    }
    $file = $_files[$filename];
    $pinfo = pathinfo($file["name"]);
    if ($filetype=="null") {
        $filetype = $pinfo['extension'];
    }
    if (!in_array(strtolower($pinfo['extension']),array("jpg","jpeg","png","gif"))) {
        dsetcookie('setok','upload3');
        header("location:111cn.net/profile");
        exit;
    }

    if($max_file_size < $file["size"]) {//检查文件大小
        dsetcookie('setok','upload2');
        header("location:111cn.net/profile");
        exit;
    }
    if(!in_array($file["type"],$uptypes)) { //检查文件类型
        dsetcookie('setok','upload3');
        header("location:111cn.net/profile");
        exit;
    }
    if(!file_exists($path_im)) {
        mkdir($path_im);
    }

    $filename = $file["tmp_name"];
    $im_size = getimagesize($filename);

    $src_w = $im_size[0];
    $src_h = $im_size[1];
    $src_type = $im_size[2];

    $all_path = $path_im.$newname.".".$filetype;//路径+文件名,目前以上传时间命名
    if (file_exists($all_path)) {
        @unlink($all_path);
    }
    if(!move_uploaded_file ($filename,$all_path)) {
        dsetcookie('setok','upload4');
        header("location:111cn.net/profile");
        exit;
    }
    $pinfo = pathinfo($all_path);
    $fname = $pinfo[basename];

    switch($src_type) {//判断源图片文件类型
         case 1://gif
         $src_im = @imagecreatefromgif($all_path);//从源图片文件取得图像
         break;
         case 2://jpg
         $src_im = @imagecreatefromjpeg($all_path);
         break;
         case 3://png
         $src_im = @imagecreatefrompng($all_path);
         break;
         //case 6:
         //$src_im=imagecreatefromwbmp($all_path);
         //break;
         default:
         dsetcookie('setok','upload3');
         header("location:111cn.net/profile");
         exit;
    }

   if($smallmark == 1) {
       if(!file_exists($path_sim)) {//检查缩略图目录是否存在,不存在创建
           mkdir($path_sim);
       }
       if ($smallname) $newname=$smallname;
       $sall_path = $path_sim.$newname.".".$filetype;
       if (file_exists($sall_path)) {
           @unlink($sall_path);
       }
       if($src_w <= $dst_sw) { // 原图尺寸 <= 缩略图尺寸
           if ($dstsh==0)  {
                $dst_sim = @imagecreatetruecolor($src_w,$src_h); //新建缩略图真彩位图
                $sx=$sy=0;
           } else {
                $dst_sim = @imagecreatetruecolor($dstsw,$dstsh); //新建缩略图真彩位图
                $sx=($dstsw-$src_w)/2;
                $sy=($dstsh-$src_h)/2;
           }
           $img = @imagecreatefrompng("images/phbg.png");
           @imagecopymerge($dst_sim,$img,0,0,0,0,$dstsw,$dstsh,100); //原图图像写入新建真彩位图中
           @imagecopymerge($dst_sim,$src_im,$sx,$sy,0,0,$src_w,$src_h,100); //原图图像写入新建真彩位图中
       }

       if($src_w > $dst_sw) { // 原图尺寸 > 缩略图尺寸
           $dst_sh = $dst_sw/$src_w*$src_h;
           if ($dst_sh<$dstsh) {
               $dst_sh=$dstsh;
               $dst_sw=$dst_sh/$src_h*$src_w;
           }
           if ($dstsh==0) {
                $dst_sim = @imagecreatetruecolor($dst_sw,$dst_sh); //新建缩略图真彩位图(等比例缩小原图尺寸)
           } else {
                $dst_sim = @imagecreatetruecolor($dstsw,$dstsh); //新建缩略图真彩位图(等比例缩小原图尺寸)
           }
           @imagecopyresampled($dst_sim,$src_im,0,0,0,0,$dst_sw,$dst_sh,$src_w,$src_h); //原图图像写入新建真彩位图中
       }

       switch($src_type) {
            case 1:@imagegif($dst_sim,$sall_path,$simclearly);//生成gif文件,图片清晰度0-100
            break;
            case 2:@imagejpeg($dst_sim,$sall_path,$simclearly);//生成jpg文件,图片清晰度0-100
            break;
            case 3:@imagepng($dst_sim,$sall_path,$simclearlypng);//生成png文件,图片清晰度0-100
            break;
            //case 6:
            //imagewbmp($dst_sim,$sall_path);
            break;
       }
       //释放缓存
       @imagedestroy($dst_sim);
    }
    @imagedestroy($src_im);
    return $newname.".".$filetype;
}
?>

[!--infotagslink--]

相关文章

  • JavaScript动态创建div属性和样式示例代码

    1.创建div元素: Javascript代码 复制代码 代码如下: <scripttypescripttype="text/javascript"> functioncreateElement(){ varcreateDiv=document.createElement("div"); createDiv.innerHTML="Testcreateadiveleme...2013-10-13
  • python 实现将Numpy数组保存为图像

    今天小编就为大家分享一篇python 实现将Numpy数组保存为图像,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-04-27
  • JS创建Tag标签的方法详解

    这篇文章主要介绍了JS创建Tag标签的方法,结合具体实例形式分析了javascript动态操作页面HTML元素实现tag标签功能的步骤与相关操作技巧,需要的朋友可以参考下...2017-06-15
  • C#图像亮度调整的方法

    这篇文章主要介绍了C#图像亮度调整的方法,涉及C#操作图像亮度的相关技巧,需要的朋友可以参考下...2020-06-25
  • 什么是cookie?js手动创建和存储cookie

    什么是cookie? cookie 是存储于访问者的计算机中的变量。每当同一台计算机通过浏览器请求某个页面时,就会发送这个 cookie。你可以使用 JavaScript 来创建和取回 cookie 的值。 有关cookie的例子: 名字 cookie 当访...2014-05-31
  • PS如何创建变形文字 ps给文字变形的方法

    PS怎么创建变形文字?ps中想要给输入的文字变形,该怎么调整文字的显示形态呢?下面我们就来看看ps给文字变形的方法,需要的朋友可以参考下 我们在图层上输入文字后,可以...2017-07-06
  • C#图像透明度调整的方法

    这篇文章主要介绍了C#图像透明度调整的方法,涉及C#操作图像透明度的相关技巧,需要的朋友可以参考下...2020-06-25
  • 快速理解MySQL中主键与外键的实例教程

    主键与外键的关系,通俗点儿讲,我现在有一个论坛,有两张表,一张是主贴 thread,一张是回帖 reply先说说主键,主键是表里面唯一识别记录的字段,一般是帖子id,体现在访问的时候,例如是 thread.php&#63;id=1 表示我要访问的是帖子...2015-11-24
  • idea 无法创建Scala class 选项的原因分析及解决办法汇总

    这篇文章主要介绍了idea 无法创建Scala class 选项的解决办法汇总,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-09-02
  • c# 接口使用实例

    这篇文章主要介绍了c#接口使用的实例,文中讲解非常细致,代码帮助大家更好的理解和学习,感兴趣的朋友可以了解下...2020-07-17
  • yii添删改查实例

    一、数据访问对象 (DAO)YiiDAO 基于 PHP Data Objects (PDO) 构建。它是一个为众多流行的DBMS提供统一数据访问的扩展,这些 DBMS 包括MySQL, PostgreSQL 等等。因此,要使用 Yii DAO,PDO 扩展和特定的 PDO 数据库驱动(例如...2015-11-24
  • php创建无限级树型菜单

    写递归函数,可考虑缓存,定义一些静态变量来存上一次运行的结果,多程序运行效率很有帮助.。 大概步骤如下: step1:到数据库取数据,放到一个数组, step2:把数据转化为一个树型状的数组, step3:把这个树型状的数组转为html代码。...2015-11-08
  • Drupal模块开发之创建自己的钩子

    Drupal可以让第三方模块创建自己的钩子。在通常的实践中,有两种类型的钩子你可能想要创建,一种是内容修改类的钩子,一种是拦截类的钩子。 Drupal的钩子系统允许和模...2016-11-25
  • C#创建Windows服务的实现方法

    这篇文章主要介绍了C#创建Windows服务的实现方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • javascript创建对象的几种模式介绍

    下面小编就为大家带来一篇javascript创建对象的几种模式介绍。小编觉得挺不错的,现在分享给大家,也给大家做个参考...2016-05-09
  • Python-numpy实现灰度图像的分块和合并方式

    今天小编就为大家分享一篇Python-numpy实现灰度图像的分块和合并方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-04-27
  • python opencv实现图像配准与比较

    这篇文章主要为大家详细介绍了python opencv实现图像配准与比较,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-02-09
  • 使用opencv识别图像红色区域,并输出红色区域中心点坐标

    这篇文章主要介绍了使用opencv识别图像红色区域,并输出红色区域中心点坐标,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-06-03
  • C#中的IEnumerable简介及简单实现实例

    这篇文章主要介绍了C#中的IEnumerable简介及简单实现实例,本文讲解了IEnumerable一些知识并给出了一个简单的实现,需要的朋友可以参考下...2020-06-25
  • php图像处理(缩放、剪裁、缩放、翻转、旋转、透明、锐化)

    本文章来给各同学总结了一些常用的图像处理函数,包括有缩放、剪裁、缩放、翻转、旋转、透明、锐化功能,大家可参考参考。 注意事项:如果要使用php gd处理我们需要...2016-11-25