当前位置:Gxlcms > PHP教程 > php给图片加文字水印与图片水印代码(1/3)_PHP教程

php给图片加文字水印与图片水印代码(1/3)_PHP教程

时间:2021-07-01 10:21:17 帮助过:5人阅读

php给图片加文字水印与图片水印代码 这款程序给图片加文字水印时是调用 了C:\\WINDOWS\\Fonts\\SIMHEI.TTF字体,给图片加水印时就可以自定图片哦。

php教程给图片加文字水印与图片水印代码
这款程序给图片加文字水印时是调用 了c:windowsfontssimhei.ttf字体,给图片加水印时就可以自定图片哦。
$image->wprint_img();//执行图片水印
$image->wprint_string();//执行文字水印
*/

class editimage{
private $imagefile;//图片文件
private $smallimg;//水印图片
private $string;//水印文字
private $position;//存放位置
private $dst_x=600;//原始图片打水印x坐标
private $dst_y=0;//原始图片打水印y坐标
private $str_x=450;
private $str_y=200;
private $font="c:windowsfontssimhei.ttf";//原始图片打水印字体路径
private $imgej;// imagecolorallocate后的变量

function __get($value){
return $this->$value;
}
function __set($property,$value){
$this->$property=$value;
}
/**
* 构造函数初始化
*
* @param string $imagefile 被上水印的文件
* @param string $smallimg 水印文件
* @param string $string 水印文字
* @param string $position 存放位置
* @param int $dst_x 被上水印的图片x
* @param int $dst_y 被上水印的图片y
*/
function __construct($imagefile,$smallimg='',$string=''){//,$position='',$dst_x=0,$dst_y=0
$this->imagefile=$imagefile;
$this->smallimg=$smallimg;
$this->string=$string;
$this->imgej=$this->imagecreatef($this->imagefile);
}

function get_extname($file){//获取文件的后缀名
if (file_exists($this->imagefile)) {
$img=getimagesize($file);
switch ($img[2]){
case "1":
return "gif";
case "2":
return "jpg";
case "3":
return "png";
}
}else{
return false;
}
}

1 2 3

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/633042.htmlTechArticlephp给图片加文字水印与图片水印代码这款程序给图片加文字水印时是调用 了C:\\WINDOWS\\Fonts\\SIMHEI.TTF字体,给图片加水印时就可以自定图片哦...

人气教程排行