全球彩票平台_全球彩票注册平台|官网下载地址

热门关键词: 全球彩票平台,全球彩票注册平台,全球彩官网下载地址

两个强悍的php,支持添加图片

//字体库
define('FONTFILE','C:/Windows/Fonts/MSYH.TTC');
$text='2020/12/31';
$fontfile='C:/Windows/Fonts/MSYH.TTC';
$newImageName=NULL;//NULL 不保留输出到浏览器;若保存文件则改为要保存的文件名
//$newImageName='D:/myWorkspace/get_img/deal_img/jiaShuiYin/aaa.jpg';
$imgData=array('src'=>'D:/myWorkspace/get_img/deal_img/jiaShuiYin/sun.jpg',
'fontcolor'=>array,
'x'=>190,
'y'=>352,
);

正文实例叙述了php_imagick达成图片剪切、旋转、锐化、减色或追加特效的方法。分享给我们供大家参照他事他说加以考察。具体解析如下:

*友好收拾的二个水印类*

复制代码 代码如下:

water_text($text,$fontfile,$imgData,$newImageName);//加水印调用函数

二个得以供PHP调用ImageMagick效用的PHP扩充。使用那几个扩展能够使PHP具有和ImageMagick同样的作用。

支撑增加图片、文字、填充颜色区域

<?php
/**
* 基本图片管理,用于达成图片缩入,水印增加
* 当水印图超越目的图片尺寸时,水印图能半自动适应指标图片而压缩
* 水印图能够设置跟背景的合併度
*
* Copyright(c) 2005 by ustb99. All rights reserved
*
* To contact the author write to {@link mailto:ustb80@163.com}
*
* @author 偶然
* @version $Id: thumb.class.php,v 1.9 2006/09/30 09:31:56 zengjian Exp $
* @package system
*/
/**
* ThumbHandler
* @access public
*/
/*
应用办法:
机关裁切:
程序会依照图片的尺码从大旨裁切最大的圆柱形,并按对象尺寸实行缩略
$t->setSrcImg("img/test.jpg");
$t->setCutType(1);//这一句就OK了
$t->setDstImg("tmp/new_test.jpg");
$t->createImg(60,60);
手工业裁切:
程序会依据钦命的岗位从源图上取图
$t->setSrcImg("img/test.jpg");
$t->setCutType(2);//指明为手工业裁切
$t->setSrcCutPosition(100, 100);// 源图起源坐标
$t->setRectangleCut(300, 200);// 裁切尺寸
$t->setDstImg("tmp/new_test.jpg");
$t->createImg(300,200);
*/
class ThumbHandler
{
var $dst_img;// 指标文件
var $h_src; // 图片能源句柄
var $h_dst;// 新图句柄
var $h_mask;// 水印句柄
var $img_create_quality = 100;// 图片生成品质
var $img_display_quality = 80;// 图片展现品质,默认为75
var $img_scale = 0;// 图片缩放比例
var $src_w = 0;// 原图宽度
var $src_h = 0;// 原图中度
var $dst_w = 0;// 新图总宽度
var $dst_h = 0;// 新图总中度
var $fill_w;// 填充图形宽
var $fill_h;// 填充图形高
var $copy_w;// 拷贝图形宽
var $copy_h;// 拷贝图形高
var $src_x = 0;// 原图绘制最初横坐标
var $src_y = 0;// 原图绘制起先纵坐标
var $start_x;// 新图绘制开首横坐标
var $start_y;// 新图绘制伊始纵坐标
var $mask_word;// 水印文字
var $mask_img;// 水印图片
var $mask_pos_x = 0;// 水印横坐标
var $mask_pos_y = 0;// 水印纵坐标
var $mask_offset_x = 5;// 水印横向偏移
var $mask_offset_y = 5;// 水印纵向偏移
var $font_w;// 水印字体宽
var $font_h;// 水印字体高
var $mask_w;// 水印宽
var $mask_h;// 水印高
var $mask_font_color = "#ffffff";// 水印文字颜色
var $mask_font = 2;// 水印字体
var $font_size;// 尺寸
var $mask_position = 0;// 水印地方
var $mask_img_pct = 50;// 图片合併程度,值越大,合併程序越低
var $mask_txt_pct = 50;// 文字统一程度,值越小,合併程序越低
var $img_border_size = 0;// 图片边框尺寸
var $img_border_color;// 图片边框颜色
var $_flip_x=0;// 水平翻转次数
var $_flip_y=0;// 垂直翻转次数
var $cut_type=0;// 剪切类型
var $img_type;// 文件类型
// 文件类型定义,并提议了出口图片的函数
var $all_type = array(
"jpg" => array("output"=>"imagejpeg"),
"gif" => array("output"=>"imagegif"),
"png" => array("output"=>"imagepng"),
"wbmp" => array("output"=>"image2wbmp"),
"jpeg" => array("output"=>"imagejpeg"));
/**
* 构造函数
*/
function ThumbHandler()
{
$this->mask_font_color = "#ffffff";
$this->font = 2;
$this->font_size = 12;
}
/**
* 取得图片的宽
*/
function getImgWidth($src)
{
return imagesx($src);
}
/**
* 取得图片的高
*/
function getImgHeight($src)
{
return imagesy($src);
}
/**
* 设置图片生成路线
*
* @param string $src_img 图片生成路线
*/
function setSrcImg($src_img, $img_type=null)
{
if(!file_exists($src_img))
{
die("图片不真实");
}
if(!emptyempty($img_type))
{
$this->img_type = $img_type;
}
else
{
$this->img_type = $this->_getImgType($src_img);
}
$this->_checkValid($this->img_type);
// file_get_contents函数供给php版本>4.3.0
$src = '';
if(function_exists("file_get_contents"))
{
$src = file_get_contents($src_img);
}
else
{
$handle = fopen ($src_img, "r");
while (!feof ($handle))
{
$src .= fgets($fd, 4096);
}
fclose ($handle);
}
if(emptyempty($src))
{
die("图片源为空");
}
$this->h_src = @ImageCreateFromString($src);
$this->src_w = $this->getImgWidth($this->h_src);
$this->src_h = $this->getImgHeight($this->h_src);
}
/**
* 设置图片生成路线
*
* @param string $dst_img 图片生成路线
*/
function setDstImg($dst_img)
{
$arr = explode('/',$dst_img);
$last = array_pop($arr);
$path = implode('/',$arr);
$this->_mkdirs($path);
$this->dst_img = $dst_img;
}
/**
* 设置图片的显示性能
*
* @param string $n 质量
*/
function setImgDisplayQuality($n)
{
$this->img_display_quality = (int)$n;
}
/**
* 设置图片的退换质量
*
* @param string $n 质量
*/
function setImgCreateQuality($n)
{
$this->img_create_quality = (int)$n;
}
/**
* 设置文字水印
*
* @param string $word 水印文字
* @param integer $font 水印字体
* @param string $color 水印字体颜色
*/
function setMaskWord($word)
{
$this->mask_word .= $word;
}
/**
* 设置字体颜色
*
* @param string $color 字体颜色
*/
function setMaskFontColor($color="#ffffff")
{
$this->mask_font_color = $color;
}
/**
* 设置水印字体
*
* @param string|integer $font 字体
*/
function setMaskFont($font=2)
{
if(!is_numeric($font) && !file_exists($font))
{
die("字体文件官样文章");
}
$this->font = $font;
}
/**
* 设置文字字体大小,仅对truetype字体有效
*/
function setMaskFontSize($size = "12")
{
$this->font_size = $size;
}
/**
* 设置图片水印
*
* @param string $img 水印图片源
*/
function setMaskImg($img)
{
$this->mask_img = $img;
}
/**
* 设置水印横向偏移
*
* @param integer $x 横向偏移量
*/
function setMaskOffsetX($x)
{
$this->mask_offset_x = (int)$x;
}
/**
* 设置水印纵向偏移
*
* @param integer $y 纵向偏移量
*/
function setMaskOffsetY($y)
{
$this->mask_offset_y = (int)$y;
}
/**
* 钦点水印地点
*
* @param integer $position 位置,1:左上,2:左下,3:右上,0/4:右下
*/
function setMaskPosition($position=0)
{
$this->mask_position = (int)$position;
}
/**
* 设置图片合併程度
*
* @param integer $n 合併程度
*/
function setMaskImgPct($n)
{
$this->mask_img_pct = (int)$n;
}
/**
* 设置文字统一程度
*
* @param integer $n 合併程度
*/
function setMaskTxtPct($n)
{
$this->mask_txt_pct = (int)$n;
}
/**
* 设置缩略图边框
*
* @param (类型) (参数名) (描述)
*/
function setDstImgBorder($size=1, $color="#000000")
{
$this->img_border_size = (int)$size;
$this->img_border_color = $color;
}
/**
* 水平翻转
*/
function flipH()
{
$this->_flip_x ;
}
/**
* 垂直翻转
*/
function flipV()
{
$this->_flip_y ;
}
/**
* 设置剪切类型
*
* @param (类型) (参数名) (描述)
*/
function setCutType($type)
{
$this->cut_type = (int)$type;
}
/**
* 设置图片剪切
*
* @param integer $width 矩形剪切
*/
function setRectangleCut($width, $height)
{
$this->fill_w = (int)$width;
$this->fill_h = (int)$height;
}
/**
* 设置源图剪切开端坐标点
*
* @param (类型) (参数名) (描述)
*/
function setSrcCutPosition($x, $y)
{
$this->src_x = (int)$x;
$this->src_y = (int)$y;
}
/**
* 成立图片,主函数
* @param integer $a 当缺少第一个参数时,此参数将用作百分比,
* 不然作为宽度值
* @param integer $b 图片缩放后的莫斯中国科学技术大学学
*/
function createImg($a, $b=null)
{
$num = func_num_args();
if(1 == $num)
{
$r = (int)$a;
if($r < 1)
{
die("图片缩放比例不行低于1");
}
$this->img_scale = $r;
$this->_setNewImgSize($r);
}
if(2 == $num)
{
$w = (int)$a;
$h = (int)$b;
if(0 == $w)
{
die("指标宽度不可能为0");
}
if(0 == $h)
{
die("目的中度无法为0");
}
$this->_setNewImgSize($w, $h);
}
if($this->_flip_x%2!=0)
{
$this->_flipH($this->h_src);
}
if($this->_flip_y%2!=0)
{
$this->_flipV($this->h_src);
}
$this->_createMask();
$this->_output();
// 释放
if(imagedestroy($this->h_src) && imagedestroy($this->h_dst))
{
Return true;
}
else
{
Return false;
}
}
/**
* 生成水印,调用了转移水印文字和水印图片两个点子
*/
function _createMask()
{
if($this->mask_word)
{
// 获取字体消息
$this->_setFontInfo();
if($this->_isFull())
{
die("水印文字过大");
}
else
{
$this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h);
$white = ImageColorAllocate($this->h_dst,255,255,255);
imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景象
$this->_drawBorder();
imagecopyresampled( $this->h_dst, $this->h_src,
$this->start_x, $this->start_y,
$this->src_x, $this->src_y,
$this->fill_w, $this->fill_h,
$this->copy_w, $this->copy_h);
$this->_createMaskWord($this->h_dst);
}
}
if($this->mask_img)
{
$this->_loadMaskImg();//加载时,获得宽高
if($this->_isFull())
{
// 将水印生成在原图上再拷
$this->_createMaskImg($this->h_src);
$this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h);
$white = ImageColorAllocate($this->h_dst,255,255,255);
imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景象
$this->_drawBorder();
imagecopyresampled( $this->h_dst, $this->h_src,
$this->start_x, $this->start_y,
$this->src_x, $this->src_y,
$this->fill_w, $this->start_y,
$this->copy_w, $this->copy_h);
}
else
{
// 创立新图并拷贝
$this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h);
$white = ImageColorAllocate($this->h_dst,255,255,255);
imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景象
$this->_drawBorder();
imagecopyresampled( $this->h_dst, $this->h_src,
$this->start_x, $this->start_y,
$this->src_x, $this->src_y,
$this->fill_w, $this->fill_h,
$this->copy_w, $this->copy_h);
$this->_createMaskImg($this->h_dst);
}
}
if(emptyempty($this->mask_word) && emptyempty($this->mask_img))
{
$this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h);
$white = ImageColorAllocate($this->h_dst,255,255,255);
imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景观
$this->_drawBorder();
imagecopyresampled( $this->h_dst, $this->h_src,
$this->start_x, $this->start_y,
$this->src_x, $this->src_y,
$this->fill_w, $this->fill_h,
$this->copy_w, $this->copy_h);
}
}
/**
* 画边框
*/
function _drawBorder()
{
if(!emptyempty($this->img_border_size))
{
$c = $this->_parseColor($this->img_border_color);
$color = ImageColorAllocate($this->h_src,$c[0], $c[1], $c[2]);
imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$color);// 填充背景象
}
}
/**
* 生成水印文字
*/
function _createMaskWord($src)
{
$this->_countMaskPos();
$this->_checkMaskValid();
$c = $this->_parseColor($this->mask_font_color);
$color = imagecolorallocatealpha($src, $c[0], $c[1], $c[2], $this->mask_txt_pct);
if(is_numeric($this->font))
{
imagestring($src,
$this->font,
$this->mask_pos_x, $this->mask_pos_y,
$this->mask_word,
$color);
}
else
{
imagettftext($src,
$this->font_size, 0,
$this->mask_pos_x, $this->mask_pos_y,
$color,
$this->font,
$this->mask_word);
}
}
/**
* 生成水印图
*/
function _createMaskImg($src)
{
$this->_countMaskPos();
$this->_checkMaskValid();
imagecopymerge($src,
$this->h_mask,
$this->mask_pos_x ,$this->mask_pos_y,
0, 0,
$this->mask_w, $this->mask_h,
$this->mask_img_pct);
imagedestroy($this->h_mask);
}
/**
* 加载水印图
*/
function _loadMaskImg()
{
$mask_type = $this->_getImgType($this->mask_img);
$this->_checkValid($mask_type);
// file_get_contents函数供给php版本>4.3.0
$src = '';
if(function_exists("file_get_contents"))
{
$src = file_get_contents($this->mask_img);
}
else
{
$handle = fopen ($this->mask_img, "r");
while (!feof ($handle))
{
$src .= fgets($fd, 4096);
}
fclose ($handle);
}
if(emptyempty($this->mask_img))
{
die("水印图片为空");
}
$this->h_mask = ImageCreateFromString($src);
$this->mask_w = $this->getImgWidth($this->h_mask);
$this->mask_h = $this->getImgHeight($this->h_mask);
}
/**
* 图片输出
*/
function _output()
{
$img_type = $this->img_type;
$func_name = $this->all_type[$img_type]['output'];
if(function_exists($func_name))
{
// 判断浏览器,若是IE就不发送头
if(isset($_SERVER['HTTP_USER_AGENT']))
{
$ua = strtoupper($_SERVER['HTTP_USER_AGENT']);
if(!preg_match('/^.*MSIE.*)$/i',$ua))
{
header("Content-type:$img_type");
}
}
$func_name($this->h_dst, $this->dst_img, $this->img_display_quality);
}
else
{
Return false;
}
}
/**
* 分析颜色
*
* @param string $color 十六进制颜色
*/
function _parseColor($color)
{
$arr = array();
for($ii=1; $ii<strlen ($color); $ii )
{
$arr[] = hexdec(substr($color,$ii,2));
$ii ;
}
Return $arr;
}
/**
* 总计出地方坐标
*/
function _countMaskPos()
{
if($this->_isFull())
{
switch($this->mask_position)
{
case 1:
// 左上
$this->mask_pos_x = $this->mask_offset_x $this->img_border_size;
$this->mask_pos_y = $this->mask_offset_y $this->img_border_size;
break;
case 2:
// 左下
$this->mask_pos_x = $this->mask_offset_x $this->img_border_size;
$this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y;
break;
case 3:
// 右上
$this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x;
$this->mask_pos_y = $this->mask_offset_y $this->img_border_size;
break;
case 4:
// 右下
$this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x;
$this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y;
break;
default:
// 默许将水印放到右下,偏移钦命像素
$this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x;
$this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y;
break;
}
}
else
{
switch($this->mask_position)
{
case 1:
// 左上
$this->mask_pos_x = $this->mask_offset_x $this->img_border_size;
$this->mask_pos_y = $this->mask_offset_y $this->img_border_size;
break;
case 2:
// 左下
$this->mask_pos_x = $this->mask_offset_x $this->img_border_size;
$this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size;
break;
case 3:
// 右上
$this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size;
$this->mask_pos_y = $this->mask_offset_y $this->img_border_size;
break;
case 4:
// 右下
$this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size;
$this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size;
break;
default:
// 私下认可将水印放到右下,偏移钦命像素
$this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size;
$this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size;
break;
}
}
}
/**
* 设置字体消息
*/
function _setFontInfo()
{
if(is_numeric($this->font))
{
$this->font_w = imagefontwidth($this->font);
$this->font_h = imagefontheight($this->font);
// 计算水印字体所占宽高
$word_length = strlen($this->mask_word);
$this->mask_w = $this->font_w*$word_length;
$this->mask_h = $this->font_h;
}
else
{
$arr = imagettfbbox ($this->font_size,0, $this->font,$this->mask_word);
$this->mask_w = abs($arr[0] - $arr[2]);
$this->mask_h = abs($arr[7] - $arr[1]);
}
}
/**
* 设置新图尺寸
*
* @param integer $img_w 指标宽度
* @param integer $img_h 指标高度
*/
function _setNewImgSize($img_w, $img_h=null)
{
$num = func_num_args();
if(1 == $num)
{
$this->img_scale = $img_w;// 宽度作为比例
$this->fill_w = round($this->src_w * $this->img_scale / 100) - $this->img_border_size*2;
$this->fill_h = round($this->src_h * $this->img_scale / 100) - $this->img_border_size*2;
// 源文件初始坐标
$this->src_x = 0;
$this->src_y = 0;
$this->copy_w = $this->src_w;
$this->copy_h = $this->src_h;
// 指标尺寸
$this->dst_w = $this->fill_w $this->img_border_size*2;
$this->dst_h = $this->fill_h $this->img_border_size*2;
}
if(2 == $num)
{
$fill_w = (int)$img_w - $this->img_border_size*2;
$fill_h = (int)$img_h - $this->img_border_size*2;
if($fill_w < 0 || $fill_h < 0)
{
die("图片边框过大,已超过了图片的上涨的幅度");
}
$rate_w = $this->src_w/$fill_w;
$rate_h = $this->src_h/$fill_h;
switch($this->cut_type)
{
case 0:
// 假若原图大于缩略图,爆发裁减,不然不收缩
if($rate_w < 1 && $rate_h < 1)
{
$this->fill_w = (int)$this->src_w;
$this->fill_h = (int)$this->src_h;
}
else
{
if($rate_w >= $rate_h)
{
$this->fill_w = (int)$fill_w;
$this->fill_h = round($this->src_h/$rate_w);
}
else
{
$this->fill_w = round($this->src_w/$rate_h);
$this->fill_h = (int)$fill_h;
}
}
$this->src_x = 0;
$this->src_y = 0;
$this->copy_w = $this->src_w;
$this->copy_h = $this->src_h;
// 目的尺寸
$this->dst_w = $this->fill_w $this->img_border_size*2;
$this->dst_h = $this->fill_h $this->img_border_size*2;
break;
// 自动裁切
case 1:
// 如若图片是压缩剪切才开展操作
if($rate_w >= 1 && $rate_h >=1)
{
if($this->src_w > $this->src_h)
{
$src_x = round($this->src_w-$this->src_h)/2;
$this->setSrcCutPosition($src_x, 0);
$this->setRectangleCut($fill_h, $fill_h);
$this->copy_w = $this->src_h;
$this->copy_h = $this->src_h;
}
elseif($this->src_w < $this->src_h)
{
$src_y = round($this->src_h-$this->src_w)/2;
$this->setSrcCutPosition(0, $src_y);
$this->setRectangleCut($fill_w, $fill_h);
$this->copy_w = $this->src_w;
$this->copy_h = $this->src_w;
}
else
{
$this->setSrcCutPosition(0, 0);
$this->copy_w = $this->src_w;
$this->copy_h = $this->src_w;
$this->setRectangleCut($fill_w, $fill_h);
}
}
else
{
$this->setSrcCutPosition(0, 0);
$this->setRectangleCut($this->src_w, $this->src_h);
$this->copy_w = $this->src_w;
$this->copy_h = $this->src_h;
}
// 目的尺寸
$this->dst_w = $this->fill_w $this->img_border_size*2;
$this->dst_h = $this->fill_h $this->img_border_size*2;
break;
// 手工业裁切
case 2:
$this->copy_w = $this->fill_w;
$this->copy_h = $this->fill_h;
// 目的尺寸
$this->dst_w = $this->fill_w $this->img_border_size*2;
$this->dst_h = $this->fill_h $this->img_border_size*2;
break;
default:
break;
}
}
// 指标文件开头坐标
$this->start_x = $this->img_border_size;
$this->start_y = $this->img_border_size;
}
/**
* 检查水印图是还是不是越过生成后的图样宽高
*/
function _isFull()
{
Return ( $this->mask_w $this->mask_offset_x > $this->fill_w
|| $this->mask_h $this->mask_offset_y > $this->fill_h)
?true:false;
}
/**
* 检查水印图是还是不是超越原图
*/
function _checkMaskValid()
{
if( $this->mask_w $this->mask_offset_x > $this->src_w
|| $this->mask_h $this->mask_offset_y > $this->src_h)
{
die("水印图片尺寸大于原图,请降低水印图");
}
}
/**
* 获得图片类型
*
* @param string $file_path 文件路线
*/
function _getImgType($file_path)
{
$type_list = array("1"=>"gif","2"=>"jpg","3"=>"png","4"=>"swf","5" => "psd","6"=>"bmp","15"=>"wbmp");
if(file_exists($file_path))
{
$img_info = @getimagesize ($file_path);
if(isset($type_list[$img_info[2]]))
{
Return $type_list[$img_info[2]];
}
}
else
{
die("文件海市蜃楼,不能够赢得文件类型!");
}
}
/**
* 检查图片类型是或不是合法,调用了array_key_exists函数,此函数必要
* php版本大于4.1.0
*
* @param string $img_type 文件类型
*/
function _checkValid($img_type)
{
if(!array_key_exists($img_type, $this->all_type))
{
Return false;
}
}
/**
* 按钦点路线生成目录
*
* @param string $path 路径
*/
function _mkdirs($path)
{
$adir = explode('/',$path);
$dirlist = '';
$rootdir = array_shift($adir);
if(($rootdir!='.'||$rootdir!='..')&&!file_exists($rootdir))
{
@mkdir($rootdir);
}
foreach($adir as $key=>$val)
{
if($val!='.'&&$val!='..')
{
$dirlist .= "/".$val;
$dirpath = $rootdir.$dirlist;
if(!file_exists($dirpath))
{
@mkdir($dirpath);
@chmod($dirpath,0777);
}
}
}
}
/**
* 垂直翻转
*
* @param string $src 图片源
*/
function _flipV($src)
{
$src_x = $this->getImgWidth($src);
$src_y = $this->getImgHeight($src);
$new_im = imagecreatetruecolor($src_x, $src_y);
for ($y = 0; $y < $src_y; $y )
{
imagecopy($new_im, $src, 0, $src_y - $y - 1, 0, $y, $src_x, 1);
}
$this->h_src = $new_im;
}
/**
* 水平翻转
*
* @param string $src 图片源
*/
function _flipH($src)
{
$src_x = $this->getImgWidth($src);
$src_y = $this->getImgHeight($src);
$new_im = imagecreatetruecolor($src_x, $src_y);
for ($x = 0; $x < $src_x; $x )
{
imagecopy($new_im, $src, $src_x - $x - 1, 0, $x, 0, 1, $src_y);
}
$this->h_src = $new_im;
}
}
利用实例:
< ?php
require_once('lib/thumb.class.php');
$t = new ThumbHandler();
$t->setSrcImg("img/test.jpg");
$t->setDstImg("tmp/new_test.jpg");
$t->setMaskImg("img/test.gif");
$t->setMaskPosition(1);
$t->setMaskImgPct(80);
$t->setDstImgBorder(4,"#dddddd");
// 内定缩放比例
$t->createImg(300,200);
?>
<?php
require_once('lib/thumb.class.php');
$t = new ThumbHandler();
// 基本使用
$t->setSrcImg("img/test.jpg");
$t->setMaskWord("test");
$t->setDstImgBorder(10,"#dddddd");
// 内定缩放比例
$t->createImg(50);
?>
<?php
equire_once('lib/thumb.class.php');
$t = new ThumbHandler();
// 基本采纳
$t->setSrcImg("img/test.jpg");
$t->setMaskWord("test");
// 钦点固定宽高
$t->createImg(200,200);
?>
<?php
require_once('lib/thumb.class.php');
$t = new ThumbHandler();
$t->setSrcImg("img/test.jpg");
$t->setDstImg("tmp/new_test.jpg");
$t->setMaskWord("test");
// 钦命固定宽高
$t->createImg(200,200);
?>
<?php
require_once('lib/thumb.class.php');
$t = new ThumbHandler();
$t->setSrcImg("img/test.jpg");
// 内定字体文件地方
$t->setMaskFont("c:/winnt/fonts/arial.ttf");
$t->setMaskFontSize(20);
$t->setMaskFontColor("#ffff00");
$t->setMaskWord("test3333333");
$t->setDstImgBorder(99,"#dddddd");
$t->createImg(50);
?>
<?php
require_once('lib/thumb.class.php');
$t = new ThumbHandler();
$t->setSrcImg("img/test.jpg");
$t->setMaskOffsetX(55);
$t->setMaskOffsetY(55);
$t->setMaskPosition(1);
//$t->setMaskPosition(2);
//$t->setMaskPosition(3);
//$t->setMaskPosition(4);
$t->setMaskFontColor("#ffff00");
$t->setMaskWord("test");
// 内定固定宽高
$t->createImg(50);
?>
<?php
require_once('lib/thumb.class.php');
$t = new ThumbHandler();
$t->setSrcImg("img/test.jpg");
$t->setMaskFont("c:/winnt/fonts/simyou.ttf");
$t->setMaskFontSize(20);
$t->setMaskFontColor("#ffffff");
$t->setMaskTxtPct(20);
$t->setDstImgBorder(10,"#dddddd");
$text = "中文";
$str = mb_convert_encoding($text, "UTF-8", "gb2312");
$t->setMaskWord($str);
$t->setMaskWord("test");
// 钦命固定宽高
$t->createImg(50);
?>

/*
参数:$src--图片地址,$text--要增添的文字;$fontsize--文字大小;$jiaodu--文字偏角;$x--文字左上角x;$y--文字左上角y;
$fontcolor=array---文字颜色,数组,长度3,红玛瑙红颜色分配;$fontfile--字体文件路线,暗许Fonts/times.ttf
water_text($src,$text='',$text2='',$fontsize=20,$jiaodu=0,$x=0,$y=0,$x2=0,$y2=0,$fontcolor=array,$fontfile='Fonts/times.ttf')
*/
function water_text($text,$fontfile,$imgData,$newImageName){

ImageMagick是一套功用庞大、稳固并且无需付费的工具集和开荒包,能够用来读、写和管理抢先185种为主格式的图纸文件,包罗流行的TIFF, JPEG, GIF, PNG, PDF以及PhotoCD等格式。利用ImageMagick,你能够依靠web应用程序的急需动态生成图片, 仍是能够对一个(或一组)图片张开更动大小、旋转、锐化、减色或扩充特效等操作,并将操作的结果以平等格式或另外格式保存。

 代码如下

您只怕感兴趣的稿子:

  • 利用PHP生成二维码的两种艺术(带logo图像)
  • php图像管理函数大全(推荐收藏)
  • 基于OpenCV的PHP图像人脸识别才能
  • PHP图片裁剪函数(保持图像不改变形)
  • PHP GD库生成图像的多少个函数总括
  • PHP图像管理之imagecreate、imagedestroy函数介绍
  • PHP中绘制图像的部分函数总括
  • PHP GD 图像管理组件的常用函数总结
  • PHP图像处理之使用imagecolorallocate()函数设置颜色例子
  • php中使用Imagick实现图像直方图的兑今世码
  • PHP入门教程之图像管理才能分析

$fontsize=15;//字体大小
$jiaodu=0;//字体旋转角度
$x=$imgData['x'];//加水印x轴
$y=$imgData['y'];//加水印y轴
$src=$imgData['src'];//原图路线
$fontcolor=$imgData['fontcolor'];//字体颜色

php_imagick是PHP对图片管理的一个扩充包,能够做到对图纸改换大小、旋转、锐化、减色或扩大特效等操作。

<?php

//图片相关消息数组
$arr=getimagesize;
ifreturn '读取图片出错';
switch{
//索引 2 付出的是图像的项目,再次回到的是数字,当中1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 = PSD
case 1:$img=imagecreatefromgif;break;
case 2:$img=imagecreatefromjpeg;break;
case 3:$img=imagecreatefrompng;break;
//default:;
}

一、windows下安装Imagick扩展:

/**

if(!is_array($fontcolor)||count($fontcolor)<3)return 0;
if(!file_exists($fontfile))$fontfile=FONTFILE;
if(!file_exists($fontfile))return 'fontfile was not found';

1、下载 ImageMagick并安装

 * 图片加水印类,辅助文字水印、反射率设置、自定义水印地方等。

//文字的宽高
$box=imagettfbbox($fontsize,$jiaodu,$fontfile,$text);
$k=max($box[2], $box[4]) - min($box[0], $box[6]);
$g=max($box[1], $box[3]) - min($box[5], $box[7]);
//设置左下脚
$x1=$x;
$y1=$y $g;
//文字颜色
$color=imagecolorallocate($img,$fontcolor[0],$fontcolor[1],$fontcolor[2]);
//写入字符串
imagettftext($img,$fontsize,$jiaodu,$x1,$y1,$color,$fontfile,$text);

 * 使用示例:

switch{
case 1:header('content-type:image/gif');imagegif($img,$newImageName,100);break;
case 2:header('content-type:image/jpeg');imagejpeg($img,$newImageName,100);break;
case 3:header('content-type:image/png');imagepng($img,$newImageName,100);break;
}
return 1;
}

2、下载php_imagick.dll

 *   $obj = new WaterMask($imgFileName);       //实例化对象

 *   $obj->$waterType = 1;           //类型:0为文字水印、1为图片水印

若果你用的是线程安全的php,请下载

 *   $obj->$transparent = 45;         //水印光滑度

windows-builds/php53/imagick-2.3.0-dev/vc9_zts/php_imagick.dll

 *   $obj->$waterStr = 'icp.niufee.com';        //水印文字

3、设置

 *   $obj->$fontSize = 18;           //文字字体大小

在php.ini中添加

 *   $obj->$fontColor = array(255,255,255);        //水印文字颜色(CRUISERGB)

extension=php_imagick.dll ,重启web server

 *   $obj->$fontFile = 'AHGBold.ttf';       //字体文件

二、linux下安装Imagick扩展:

 *   ……

1.yum安装ImageMagick

 *   $obj->output();              //输出水印图片文件覆盖到输入的图样文件

yum install ImageMagick ImageMagick-devel

 * @modify liuzp111

2.测量检验是或不是安装成功

 */

convert -version

classWaterMask{

3.安装imagick扩展
 
01.wget xzvf imagick-3.1.0RC2.tgz03.cd imagick-3.1.0RC204.phpize05../configure06.make07.make install

  public$waterTypeImage  = false;               //水印类型:启用图片水印

4.编辑php.ini文件,在文书末尾增加如下代码

  public$waterTypeStr   = false;         //水印类型:启用文字水印

extension=imagick.so

  public$pos       = 0;         //水印地方

  1. 再也启航apache服务器

  public$transparent   = 45;        //水印反射率(0---100)数值越大越不透明

service httpd restart

 

三、案例

  public$waterStr     ='icp.niufee.com';     //水印文字

  1. 边框管理

  public$fontSize     = 14;        //文字字体大小

复制代码 代码如下:

  public$fontColor    =array(0,0,0);         //水印文字颜色(EnclaveGB) 私下认可深红

header('Content-type: image/jpeg'); 
$image = new Imagick('test.jpg'); 
$color=new ImagickPixel(); 
$color->setColor("rgb(220,220,220)"); 
$image->borderImage($color,5,4); 
$image->blurImage(5,5,imagick::CHANNEL_GREEN); 
echo $image;

  public$fontFile     ='./font/simfang.ttf';     //字体文件

我们先来看个简易的实例

 

php_imagick程序示例

  public$waterImg     ='logo.png';      //水印图片

1.创办八个缩略图并展示出来

 

复制代码 代码如下:

  private$srcImg      ='';        //需求丰硕水印的图样

<?php 
header('Content-type: image/jpeg'); 
$image = new Imagick('image.jpg'); 
// If 0 is provided as a width or height parameter,// aspect ratio is maintained 
$image->thumbnailImage(100, 0); 
echo $image; 
?>

  private$im        ='';        //图片句柄

2.创办贰个索引下的缩略图,并保存

  private$water_im     ='';        //水印图片句柄

复制代码 代码如下:

  private$srcImg_info   ='';        //图片音信

<?php 
$images = new Imagick(glob('images/*.JPG')); 
foreach($images as $image) { 
// Providing 0 forces thumbnailImage to maintain aspect ratio  
$image->thumbnailImage(1024,0); 

$images->writeImages(); 
?>

  private$waterImg_info  ='';        //水印图片消息

3.缩略GIF动画图片

  private$str_w      ='';        //水印文字宽度

复制代码 代码如下:

  private$str_h      ='';        //水印文字高度

<?php 
/* Create a new imagick object and read in GIF */
$im = new Imagick("example.gif"); 
/* Resize all frames */
foreach ($im as $frame) { 
/* 50x50 frames */
$frame->thumbnailImage(50, 50); 
/* Set the virtual canvas to correct size */
$frame->setImagePage(50, 50, 0, 0); 
}/* Notice writeImages instead of writeImage */
$im->writeImages("example_small.gif", true); 
?>

  private$x        ='';        //水印X坐标

以往大家步向正题吧,

  private$y        ='';        //水印y坐标

示例:

  public$output_img    ='';                 //存款和储蓄输出图片到哪里

裁切/生成缩略图/增多水印, 自动物检疫验和拍卖 GIF

  public$is_draw_rectangle= false;                 //是或不是绘制矩形区域 (暂不补助自定义地方)

调用格局:

  //public $rectange_color   = '';                  //绘制矩形区域的颜色 

复制代码 代码如下:

  private$result_array   =array();              //结果数组

include 'imagick.class.php'; 
$image = new lib_image_imagick(); 
$image->open('a.gif'); 
$image->resize_to(100, 100, 'scale_fill'); 
$image->add_text('1024i.com', 10, 20); 
$image->add_watermark('1024i.gif', 10, 50); 
$image->save_to('x.gif');
imagick.class.php

  publicfunction__construct($img) {   //析构函数

<?php 
class lib_image_imagick 

 private $image = null; 
 private $type = null; 
 // 构造函数 
 public function __construct(){} 
 
 // 析构函数 
 public function __destruct() 
 { 
     if($this->image!==null) $this->image->destroy();  
 } 
 // 载入图像 
 public function open($path) 
 { 
  $this->image = new Imagick( $path ); 
  if($this->image) 
  { 
      $this->type = strtolower($this->image->getImageFormat()); 
  } 
  return $this->image; 
 } 
  
 public function crop($x=0, $y=0, $width=null, $height=null) 
 { 
     if($width==null) $width = $this->image->getImageWidth()-$x; 
     if($height==null) $height = $this->image->getImageHeight()-$y; 
     if($width<=0 || $height<=0) return; 
      
     if($this->type=='gif') 
     { 
            $image = $this->image; 
         $canvas = new Imagick(); 
          
         $images = $image->coalesceImages(); 
         foreach($images as $frame){ 
             $img = new Imagick(); 
             $img->readImageBlob($frame); 
                $img->cropImage($width, $height, $x, $y); 
                $canvas->addImage( $img ); 
                $canvas->setImageDelay( $img->getImageDelay() ); 
                $canvas->setImagePage($width, $height, 0, 0); 
            } 
             
            $image->destroy(); 
         $this->image = $canvas; 
     } 
     else
     { 
         $this->image->cropImage($width, $height, $x, $y); 
     } 
 } 
 /*
 * 更动图像大小 
 $fit: 适应大小格局 
 'force': 把图片强制变变成 $width X $height 大小 
 'scale': 按百分比在广元框 $width X $height 内缩放图片, 输出缩放后图像大小 不完全等于 $width X $height 
 'scale_fill': 按百分比在广安框 $width X $height 内缩放图片,安全框内未有像素的地方填充色, 使用此参数时可安装背景填充色 $bg_color = array(255,255,255)(红,绿,蓝, 发光度) 折射率(0不透明-127一心透明)) 
 另外: 智能模能 缩放图像并载取图像的中间部分 $width X $height 像素大小 
 $fit = 'force','scale','scale_fill' 时: 输出完整图像 
 $fit = 图像方位值 时, 输出钦点地点某个图像  
 字母与图像的呼应关系如下: 
  
 north_west   north   north_east 
  
 west         center        east 
  
 south_west   south   south_east 
  
 */
 public function resize_to($width = 100, $height = 100, $fit = 'center', $fill_color = array(255,255,255,0) ) 
 { 
      
     switch($fit) 
     { 
         case 'force': 
             if($this->type=='gif') 
             { 
                 $image = $this->image; 
                 $canvas = new Imagick(); 
                  
                 $images = $image->coalesceImages(); 
                 foreach($images as $frame){ 
                     $img = new Imagick(); 
                     $img->readImageBlob($frame); 
                        $img->thumbnailImage( $width, $height, false ); 
                        $canvas->addImage( $img ); 
                        $canvas->setImageDelay( $img->getImageDelay() ); 
                    } 
                    $image->destroy(); 
                 $this->image = $canvas; 
             } 
             else
             { 
                 $this->image->thumbnailImage( $width, $height, false ); 
             } 
             break; 
         case 'scale': 
             if($this->type=='gif') 
             { 
                 $image = $this->image; 
                 $images = $image->coalesceImages(); 
                 $canvas = new Imagick(); 
                 foreach($images as $frame){ 
                     $img = new Imagick(); 
                     $img->readImageBlob($frame); 
                        $img->thumbnailImage( $width, $height, true ); 
                        $canvas->addImage( $img ); 
                        $canvas->setImageDelay( $img->getImageDelay() ); 
                    } 
                    $image->destroy(); 
                 $this->image = $canvas; 
             } 
             else
             { 
                 $this->image->thumbnailImage( $width, $height, true ); 
             } 
             break; 
         case 'scale_fill': 
             $size = $this->image->getImagePage();  
             $src_width = $size['width']; 
             $src_height = $size['height']; 
              
                $x = 0; 
                $y = 0; 
                 
                $dst_width = $width; 
                $dst_height = $height; 
    if($src_width*$height > $src_height*$width) 
    { 
     $dst_height = intval($width*$src_height/$src_width); 
     $y = intval( ($height-$dst_height)/2 ); 
    } 
    else
    { 
     $dst_width = intval($height*$src_width/$src_height); 
     $x = intval( ($width-$dst_width)/2 ); 
    } 
                $image = $this->image; 
                $canvas = new Imagick(); 
                 
                $color = 'rgba('.$fill_color[0].','.$fill_color[1].','.$fill_color[2].','.$fill_color[3].')'; 
             if($this->type=='gif') 
             { 
                 $images = $image->coalesceImages(); 
                 foreach($images as $frame) 
                 { 
                     $frame->thumbnailImage( $width, $height, true ); 
                     $draw = new ImagickDraw(); 
                        $draw->composite($frame->getImageCompose(), $x, $y, $dst_width, $dst_height, $frame); 
                        $img = new Imagick(); 
                        $img->newImage($width, $height, $color, 'gif'); 
                        $img->drawImage($draw); 
                        $canvas->addImage( $img ); 
                        $canvas->setImageDelay( $img->getImageDelay() ); 
                        $canvas->setImagePage($width, $height, 0, 0); 
                    } 
             } 
             else
             { 
                 $image->thumbnailImage( $width, $height, true ); 
                  
                 $draw = new ImagickDraw(); 
                    $draw->composite($image->getImageCompose(), $x, $y, $dst_width, $dst_height, $image); 
                     
                 $canvas->newImage($width, $height, $color, $this->get_type() ); 
                    $canvas->drawImage($draw); 
                    $canvas->setImagePage($width, $height, 0, 0); 
             } 
             $image->destroy(); 
             $this->image = $canvas; 
             break; 
   default: 
    $size = $this->image->getImagePage();  
       $src_width = $size['width']; 
             $src_height = $size['height']; 
              
                $crop_x = 0; 
                $crop_y = 0; 
                 
                $crop_w = $src_width; 
                $crop_h = $src_height; 
                 
          if($src_width*$height > $src_height*$width) 
    { 
     $crop_w = intval($src_height*$width/$height); 
    } 
    else
    { 
        $crop_h = intval($src_width*$height/$width); 
    } 
                 
       switch($fit) 
             { 
        case 'north_west': 
            $crop_x = 0; 
            $crop_y = 0; 
            break; 
           case 'north': 
               $crop_x = intval( ($src_width-$crop_w)/2 ); 
               $crop_y = 0; 
               break; 
           case 'north_east': 
               $crop_x = $src_width-$crop_w; 
               $crop_y = 0; 
               break; 
           case 'west': 
               $crop_x = 0; 
               $crop_y = intval( ($src_height-$crop_h)/2 ); 
               break; 
           case 'center': 
               $crop_x = intval( ($src_width-$crop_w)/2 ); 
               $crop_y = intval( ($src_height-$crop_h)/2 ); 
               break; 
           case 'east': 
               $crop_x = $src_width-$crop_w; 
               $crop_y = intval( ($src_height-$crop_h)/2 ); 
               break; 
           case 'south_west': 
               $crop_x = 0; 
               $crop_y = $src_height-$crop_h; 
               break; 
           case 'south': 
               $crop_x = intval( ($src_width-$crop_w)/2 ); 
               $crop_y = $src_height-$crop_h; 
               break; 
           case 'south_east': 
               $crop_x = $src_width-$crop_w; 
               $crop_y = $src_height-$crop_h; 
               break; 
           default: 
               $crop_x = intval( ($src_width-$crop_w)/2 ); 
               $crop_y = intval( ($src_height-$crop_h)/2 ); 
             } 
              
             $image = $this->image; 
             $canvas = new Imagick(); 
              
          if($this->type=='gif') 
             { 
                 $images = $image->coalesceImages(); 
                 foreach($images as $frame){ 
                     $img = new Imagick(); 
                     $img->readImageBlob($frame); 
                        $img->cropImage($crop_w, $crop_h, $crop_x, $crop_y); 
                        $img->thumbnailImage( $width, $height, true ); 
                         
                        $canvas->addImage( $img ); 
                        $canvas->setImageDelay( $img->getImageDelay() ); 
                        $canvas->setImagePage($width, $height, 0, 0); 
                    } 
             } 
             else
             { 
                 $image->cropImage($crop_w, $crop_h, $crop_x, $crop_y); 
                 $image->thumbnailImage( $width, $height, true ); 
                 $canvas->addImage( $image ); 
                 $canvas->setImagePage($width, $height, 0, 0); 
             } 
             $image->destroy(); 
             $this->image = $canvas; 
     } 
      
 } 
  
 // 增多水印图片 
 public function add_watermark($path, $x = 0, $y = 0) 
 { 
        $watermark = new Imagick($path); 
        $draw = new ImagickDraw(); 
        $draw->composite($watermark->getImageCompose(), $x, $y, $watermark->getImageWidth(), $watermark->getimageheight(), $watermark); 
     if($this->type=='gif') 
     { 
         $image = $this->image; 
            $canvas = new Imagick(); 
         $images = $image->coalesceImages(); 
         foreach($image as $frame) 
         { 
                $img = new Imagick(); 
             $img->readImageBlob($frame); 
                $img->drawImage($draw); 
                 
                $canvas->addImage( $img ); 
                $canvas->setImageDelay( $img->getImageDelay() ); 
            } 
            $image->destroy(); 
         $this->image = $canvas; 
     } 
     else
     { 
         $this->image->drawImage($draw); 
     } 
 } 
  
 // 增加水印文字 
 public function add_text($text, $x = 0 , $y = 0, $angle=0, $style=array()) 
 { 
        $draw = new ImagickDraw(); 
        if(isset($style['font'])) $draw->setFont($style['font']); 
        if(isset($style['font_size'])) $draw->setFontSize($style['font_size']); 
     if(isset($style['fill_color'])) $draw->setFillColor($style['fill_color']); 
     if(isset($style['under_color'])) $draw->setTextUnderColor($style['under_color']); 
      
     if($this->type=='gif') 
     { 
         foreach($this->image as $frame) 
         { 
             $frame->annotateImage($draw, $x, $y, $angle, $text); 
         } 
     } 
     else
     { 
         $this->image->annotateImage($draw, $x, $y, $angle, $text); 
     } 
 } 
  
 // 保存到钦点路线 
 public function save_to( $path ) 
 { 
     if($this->type=='gif') 
     { 
         $this->image->writeImages($path, true); 
     } 
     else
     { 
         $this->image->writeImage($path); 
     } 
 } 
 // 输出图像 
 public function output($header = true) 
 { 
     if($header) header('Content-type: '.$this->type); 
     echo $this->image->getImagesBlob();   
 } 
  
 public function get_width() 
 { 
        $size = $this->image->getImagePage();  
        return $size['width']; 
 } 
  
 public function get_height() 
 { 
     $size = $this->image->getImagePage();  
        return $size['height']; 
 } 
 // 设置图像类型, 私下认可与源类型一致 
 public function set_type( $type='png' ) 
 { 
     $this->type = $type; 
        $this->image->setImageFormat( $type ); 
 } 
 // 获取源图像类型 
 public function get_type() 
 { 
  return $this->type; 
 } 
 
 // 当前目的是还是不是为图片 
 public function is_image() 
 { 
  if( $this->image ) 
   return true; 
  else
   return false; 
 } 
 
 public function thumbnail($width = 100, $height = 100, $fit = true){ $this->image->thumbnailImage( $width, $height, $fit );} // 生成缩略图 $fit为真时将保险比例并在固原框 $width X $height 内生成缩略图片 
 /*
 增多贰个边框 
 $width: 左侧面框宽度 
 $height: 上上面框宽度 
 $color: 颜色: HavalGB 颜色 'rgb(255,0,0)' 或 16进制颜色 '#FF0000' 或颜色单词 'white'/'red'... 
 */
 public function border($width, $height, $color='rgb(220, 220, 220)') 
 { 
  $color=new ImagickPixel(); 
  $color->setColor($color); 
  $this->image->borderImage($color, $width, $height); 
 } 
  
 public function blur($radius, $sigma){$this->image->blurImage($radius, $sigma);} // 模糊 
 public function gaussian_blur($radius, $sigma){$this->image->gaussianBlurImage($radius, $sigma);} // 高斯模糊 
 public function motion_blur($radius, $sigma, $angle){$this->image->motionBlurImage($radius, $sigma, $angle);} // 运动模糊 
 public function radial_blur($radius){$this->image->radialBlurImage($radius);} // 径向模糊 
 public function add_noise($type=null){$this->image->addNoiseImage($type==null?imagick::NOISE_IMPULSE:$type);} // 增加噪点 
  
 public function level($black_point, $gamma, $white_point){$this->image->levelImage($black_point, $gamma, $white_point);} // 调节色阶 
 public function modulate($brightness, $saturation, $hue){$this->image->modulateImage($brightness, $saturation, $hue);} // 调解亮度、饱和度、色调 
 public function charcoal($radius, $sigma){$this->image->charcoalImage($radius, $sigma);} // 素描 
 public function oil_paint($radius){$this->image->oilPaintImage($radius);} // 水墨画效果 
  
 public function flop(){$this->image->flopImage();} // 水平翻转 
 public function flip(){$this->image->flipImage();} // 垂直翻转 
}

    //$this->srcImg = file_exists($img) ? $img : die('"'.$img.'" 源文件不真实!');

指望本文所述对我们的PHP程序设计有着补助。

    if(file_exists($img)){

您大概感兴趣的稿子:

  • php基于CodeIgniter实现图片上传、剪切作用
  • php完结图片上传、剪切功能
  • php等比例缩放图片及剪切图片代码分享
  • php图片水印加多,压缩,剪切的封装类完成
  • PHP增多图片水印、压缩、剪切的封装类
  • php工具型代码之印章抠图

      $this->srcImg =$img;

    }else{

      returnarray('data'=>'','info'=>'源文件不设有!','status'=>0);

    }

  }

 

  privatefunctionimginfo() { //获取供给加上水印的图纸的消息,并载入图片。

    $this->srcImg_info =getimagesize($this->srcImg);

    switch($this->srcImg_info[2]) {

      case3:

        $this->im = imagecreatefrompng($this->srcImg);

        break1;

      case2:

        $this->im = imagecreatefromjpeg($this->srcImg);

        break1;

      case1:

        $this->im = imagecreatefromgif($this->srcImg);

        break1;

本文由全球彩票平台发布于全球彩票注册平台编程,转载请注明出处:两个强悍的php,支持添加图片

TAG标签: 全球彩票平台
Ctrl+D 将本页面保存为书签,全面了解最新资讯,方便快捷。