$image->wprint_img();//执行图片水印
$image->wprint_string();//执行文字水印
*/
代码如下 | 复制代码 |
class editimage{ function get_extname($file){//获取文件的后缀名 |
这是一段完美的php柱状图生成类代码,可以生成漂亮实用的柱状图
代码如下 | 复制代码 |
function createimage($data,$twidth,$tspace,$height){ $dataname = array(); $datavalue = array(); $i = 0; $j = 0; $k = 0; $num = sizeof($data); foreach($data as $key => $val){ $dataname[] = $key; $datavalue[] = $val; } $maxnum = max($data); $width = ($twidth + $tspace) * $num + 4;//image's width $im = imagecreate($width + 40,$height+20); $linecolor = imagecolorallocate($im,12,12,12); $bgcolor = imagecolorallocate($im,235,233,233); $tcolor = imagecolorallocate($im,123,200,56); imagefill($im,0,0,$bgcolor); imageline ( $im, 30, 0, 30, $height - 2, $linecolor); imageline ( $im, 30, $height - 2, $width + 30 -2 , $height - 2,$linecolor); while($i < $num){ imagefilledrectangle ( $im, $i * ($tspace+$twidth) + 40, $height - $datavalue[$i], $i * ($tspace+$twidth) + 40 + $twidth, $height - 3, $tcolor); imagestringup ( $im, 4, $i * ($tspace+$twidth) + $twidth/2 + 30, $height - 10, $dataname[$i]."(".$datavalue[$i].")", $linecolor); $i++; } while($j <= (500/10)){ imagestringup ( $im, 4, 2, $height - $j * 10 + 10, $j * 10, $linecolor); $j = $j + 10; } while($k <= (500/10)){ if($k != 0) imageline ( $im, 28, $height - $k * 10, 32 , $height - $k * 10,$linecolor); $k = $k + 10; } imagepng($im); } |
//调用方法:
代码如下 | 复制代码 |
header("content-type:image/png"); $data = array("yahoo" => 120, "google" => 260,"microsoft" => 320,"ibm" => 290,"sun system" => 150,"inter" => 260); createimage($data,38,25,460); |
代码如下 | 复制代码 |
/* class image_control function __construct($img_path,$is_auto_reduce,$is_appoint,$multiple,$is_water_str,$water_str,$is_watermark,$logo_path,$is_display,$is_create) function img_control() switch($img_info[2]) case 2: case 3: //文字水印 //图片水印 switch($logo_info[2]) case 2: case 3: //水印logo图片 //自动图片压缩 按图片大小分级自动压缩 //手动图片压缩 //图像输出 //新图像生成 for($i=0;$i<count($new_name)-1;$i++) $new_img_path=$new_name_string."new".$new_name[$i]; if(imagejpeg($new_image_get,$new_img_path) && imagejpeg($img_get,$this->img_path)) function __desctruct() |
//调用方法
代码如下 | 复制代码 |
/* $img_path="../users/user_photo/t2.jpg"; //被操作的图片路径 |
//config.php
//=================================用户配置区=================================
$per=1; //每次处理的图片数目
$dir1='img'; //输入目录
$dir2='img2'; //输出目录 输出图片会保存于$dir2/$dir1目录下面
$mark_img='www.111cn.net.gif'; //水印图片
$mark_text=''; //水印文字内容 【不支持中文】
$mark_text_size=25; //水印文字大小
$mark_pos=5; //水印位置,0为随机,1为顶端居左,2为顶端居中,3为顶端居右,4为中部居左,5为中部居中,6为中部居右,7为底端居左,8为底端居中,9为底端居右;
//=================================用户配置区【结束】=================================
代码如下 | 复制代码 |
//mark.php加水印文件 function imagewatermark( $product_img, $waterpos = 0, $waterimage = "", $watertext = "", $textfont = 25, $textcolor = "#ff0000", $newdir = "marked" ) set_time_limit( 0 ); |
echo "<center>
这款图片上传源代码是一款可以上传图片并且还具有给上传的图片生成缩略图与增加水印功能哦,可以说是一款完美的图片上传类哦。
代码如下 | 复制代码 |
class upfile { public $filesize = 1000000; //允许上传的大小 //如果要修改允许上传文件的类型 请搜索 【 switch ($upfiletype) { //文件类型 】 public $reimagesize = array ( public $india = true; //是否打水印 true打 false不打 public $indiaimage = ""; //水印图片地址为空则不打图片水印 如果有文字水印建议不要开启图片水印 public $indiaimagex = 100; //图片距离图片左边距离 public $indiaimagey = 10; //图片距离图片上面距离 public $indiatext = "www.111cn.net"; //水印文字 public $fontsize = 6; //水印文字大小,1最小6最大 public $indiatextx = 10; //文字距离图片左边距离 public $indiatexty = 10; //文字距离图片上面距离 public $r = 250; //图片颜色三原色 $r红 public $g = 250; //$g绿 public $b = 250; //$b蓝 public $indiapath = ""; //加了水印的图片保存路径,如果为空就直接替代原来的图片 //开始上传处理 } } } } <form action="" method="post" enctype="multipart/form-data"> |