php图片操作
来源:互联网 发布:ketshot 5 mac版破解 编辑:程序博客网 时间:2024/05/22 05:27
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">源于猪八戒网上的一次招标,前前后后,学到了不少东西。自己简单整理下。</span>
在图片上写文字
function Xiezi($tt,$width,$height){$image = ImageCreateFromJPEG( "test.jpg" );$cor = imagecolorallocate($image, 0, 0, 0);$font = 'xihei.ttf';//$tt = '我们的灵魂';//imagepsslantfont($font, 22.5);$a = im($image, 12, 0, $width, $height, $cor, $font, $tt,3);//header('Content-type: image/jpeg');imagejpeg($image,"test.jpg");}function im(&$image, $size, $angle, $start_x, $y, $color, $font, $text,$spancing) { for ($i=0;$i<mb_strlen($text,'utf8');$i++) { $t = mb_substr($text, $i,1,'utf8'); $x = $i*($size+$spancing); imagettftext($image, $size, $angle, $x+$start_x, $y, $color, $font, $t); } }
图片的缩放操作
//图片缩放function thumb($filename,$width=200,$height=200){list($width_org,$height_org)=getimagesize($filename);/*if($width && ($width_org < $height_org)){$width=($height/$height_org)*$width_org;}else{$height=($width/$width_org)*$height_org;}*///如果上面代码没被注释 那么是等比例缩放$image_p=imagecreatetruecolor($width, $height);$image=imagecreatefromjpeg($filename);imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_org, $height_org);imagejpeg($image_p,$filename,100);imagedestroy($image_p);imagedestroy($image);}
加水印函数
//加水印的函数function watermark($filename,$water){list($b_w,$b_h)=getimagesize($filename);list($w_w,$w_h)=getimagesize($water);$posX=rand(0,($b_w-$w_w));$posY=rand(0,($b_h-$b_h));$back=imagecreatefromjpeg($filename);$water=imagecreatefromjpeg($water);imagecopy($back, $water, 519, 111, 0, 0, $w_w, $w_h);imagejpeg($back,"test.jpg");imagedestroy($back);imagedestroy($water);}
生成随机字符串
//生成随机字符串function getRandChar($length){ $str = null; $strPol = "0123456789"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数 } return $str;}
字符串逐字拆分函数
function arr_split_zh($tempaddtext){ $tempaddtext = iconv("UTF-8", "gb2312", $tempaddtext); $cind = 0; $arr_cont=array(); for($i=0;$i<strlen($tempaddtext);$i++) { if(strlen(substr($tempaddtext,$cind,1)) > 0){ if(ord(substr($tempaddtext,$cind,1)) < 0xA1 ){ //如果为英文则取1个字节 array_push($arr_cont,substr($tempaddtext,$cind,1)); $cind++; }else{ array_push($arr_cont,substr($tempaddtext,$cind,2)); $cind+=2; } } } foreach ($arr_cont as &$row) { $row=iconv("gb2312","UTF-8",$row); }return $arr_cont;}
0 0
- php图片操作
- php图片操作
- PHP 上传图片操作流程
- 【PHP】操作图片函数实例
- 【PHP】图片操作类 - 水印、缩略图
- php 对图片的验证操作
- PHP操作MongoDB 存储图片 文件
- php 文件操作函数 之 图片计数器
- php image函数,操作压缩图片时,png图片压缩后整个图片变黑
- php 操作 MySQL 中的Blob类型 存储图片
- 分享 php 将图片转为数据流入库还原操作
- php 操作 MySQL 中的Blob类型 存储图片
- php 操作 MySQL 中的Blob类型 存储图片
- PHP操作MongoDB GridFS 存储文件,如图片文件
- 实用的php增删改查库(包含图片操作)
- 图片操作
- 图片操作
- php操作php文件
- 第十六天:集合-List实现类、泛型
- 学习笔记(六) 网络编程与数据处理
- TCP、UDP、HTTP、SOCKET之间的区别
- servlet的请求方式
- NOI2.5 1253:Dungeon Master
- php图片操作
- hdu 3635题意分析
- cocos creator editbox控件用法
- ThinkPHP 模板视图
- JavaScript强化教程——JavaScript Math(算数) 对象
- ORACLE分页查询SQL语法——最高效的分页
- MUI框架教程 基于localStorage的便签APP开发源码实例
- 自然语言处理入门
- oracle 数据库中的一些基本语句