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
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号