失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 利用php GD库 文字图片水印 缩略图

利用php GD库 文字图片水印 缩略图

时间:2022-09-24 18:25:15

相关推荐

利用php GD库 文字图片水印 缩略图

php教程|PHP源码

image,this,quot,gt,info

php教程-PHP源码

GD库是php中一个默认的强大的图片处理库了,我们可以利用它来对图片进行一些操作或生成图片的操作,下面我们来看文字图片水印缩略图在php中的实例。

ec(2);一:添加文字水印 使用方法

html5获取手机型号源码,vscode微信红包封面,引导ubuntu黑屏,tomcat内存占用查看,爬虫站长之家,js php 按钮,付费seo优化多少钱,手机网站快速建站,网站程序 模板lzw

require ‘image.class.php’

$src=”001.jpg”;

$content=”hello”;

$font_url=”my.ttf”;

$size=20;

$image=new Image($src);

$color=array(

0=>255,

1=>255,

2=>255,

2=>20

);

$local=array(

‘x’=>20,

‘y’=>30

);

$angle=10;

$image->fontMark($content,$font_url,$size,$color,$local,$angle);

$image->show();

自动发号源码,vscode打开终端失败,ubuntu 文件查看,tomcat 无法发布,sqlite测试工具,注册网页设计公司,获取web.config数据库连接字符串,服务器php环境,ecshop 滑动插件,前端主流框架有什么作用,爬虫系统分类,php 大马,中山关键词seo,掌握springboot,jquery标签页,如何直到网站是用什么模板做的,网页象棋游戏源码,高端策划书模板,网站后台系统有哪些,404页面模版,ssh管理系统,matlab画图程序lzw

二:图片缩略图 使用方法:

摄影 网站模板源码免费下载,ubuntu电脑设置分屏,tomcat4版本怎么看,鱼池过滤有爬虫,php制作图形计算器代码,西南seo优化lzw

require ‘image.class.php’

$src=”001.jpg”;

$image=new Image($src);

$image->thumb(300,200);

$image->show();

三:image.class.php

class image{

private $info;

private $image;

public function __contruct($src){

$info= getimagesize($src);

$this->info=array(

‘width’=> $info[0],

‘height’=>$info[1],

‘type’=>image_type_to_extension($info[2],false),

‘mime’=>$info[‘mime’],

);

$fun=”imagecreatefrom{$this->info[‘type’]}”;

$this->image= $fun($src);

}

//缩略图

public function thumd($width,$height){

$image_thumb= imagecreatetruecolor($width,$height);

imagecopyresampled($image_thumb,$this->image,0,0,0,0,$width,$height,$this->info[‘width’],$this->info[‘height’]);

imagedestroy($this->image);

$this->image=$image_thumb;

}

//文字水印

public function fontMark($content,$font_url,$size,$color,$local,$angle){

$col=imagecolorallocatealpha($this->image,$color[0],$color[1],$color[2],$color[3]);

$text=imagettftext($this->image,$size,$angle,$local[‘x’],$local[‘y’],$col,$font_url,$content);

}

//输出图片

public function show()

{

header(“Content-type:”,$this->info[‘mime’]);

$func=”image{$this->info[‘type’]}”;

$func($this->image);

}

public function save($nwename){

$func=”image{$this->info[‘type’]}”;

//从内存中取出图片显示

$func($this->image);

//保存图片

$func($this->image,$nwename.$this->info[‘type’]);

}

public function _destruct(){

imagedestroy($this->image);

}

}

如果觉得《利用php GD库 文字图片水印 缩略图》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。