当前位置:网站首页>php生成文字图片水印
php生成文字图片水印
2022-07-27 10:07:00 【Luckinman】
一、素材准备
电脑一个,图片一张,字体库一个,哦了

字体库在哪找呢?C盘——Fonts文件夹


搜微软雅黑就可以了
二、代码实现
<?php
//配置图片信息
$src="cat.jpg";
//获取图片信息
$info=getimagesize($src);
//通过图像的编号获图片的类型
$type=image_type_to_extension($info[2],false); //.jpeg 如果不想要点 就false掉
//在内存中创建一个和我们图像类型一样的图像
$fun="imagecreatefrom{$type}";
$image=$fun($src);
//设置字体的路径
$font="msyhbd.ttc";
//填写我们的水印内容
$content="我爱你中国";
//设置字体的颜色和透明度
$col=imagecolorallocatealpha($image,255,255,255,50);
//写入文字
imagettftext($image,20,0,20,30,$col,$font,$content);
//浏览器输出
header('Content-type:'.$info['mime']);
$func = "image{$type}";
$func($image);
//保存图片
$func($image,'save.'.$type);
//销毁图片
imagedestroy($image);
?>三、 本地运行即可

边栏推荐
- 安装CUDA失败的情况nsight visual studio edition失败
- 解决ORCLE-ORA-01122 01110 01210
- 文件上传漏洞相关
- Basic statement of database operation
- Decision tree principle and case application - Titanic survival prediction
- 多点双向重发布和路由策略
- gyp ERR! configure error. gyp ERR! stack Error: gyp failed with exit code: 1
- Pyautogui realizes automatic office -rpa small case
- Shell read read console input, use of read
- 【Flutter】SharedPreferences使用
猜你喜欢

女粉想要找男朋友,竟是为了...

samba服务器

让人深思:句法真的重要吗?邱锡鹏组提出一种基于Aspect的情感分析的强大基线...

邮件服务器
[email protected], "/>Shell variables, system predefined variables $home, $pwd, $shell, $user, custom variables, special variables $n, $, $*, [email protected],
![Text processing tool in shell, cut [option parameter] filename Description: the default separator is the built-in variable of tab, awk [option parameter] '/pattern1/{action1}filename and awk](/img/ed/941276a15d1c4ab67d397fb3286022.png)
Text processing tool in shell, cut [option parameter] filename Description: the default separator is the built-in variable of tab, awk [option parameter] '/pattern1/{action1}filename and awk

怎样关闭电脑开机自启动的应用

warning package.json: No license field报错

北京公示儿童鞋抽查 8组批产品不合格琪尔特登榜

ctf (hardrce)
随机推荐
How to turn off the application of computer self startup
声音处理之-梅尔频率倒谱系数(MFCC)
Oracle调整数据文件大小杂谈
Decision tree principle and case application - Titanic survival prediction
Redis数据结构分析(二)
【Liunx】安装MySQL
数据库性能系列之子查询
【英雄哥六月集训】第 26天: 并查集
【精选】如何完美的写 PHP 代码的呢?
hugo学习笔记
Sub query of database performance series
Ubuntu and MySQL quick start tutorial
Understanding and code implementation of Se (sequence and exception) module
FTP 服务器
数据库操作基础语句
Understanding of batchnorm2d() function in pytorch
Oracle 11g manual memory management
gyp ERR! configure error. gyp ERR! stack Error: gyp failed with exit code: 1
01_ Movie recommendation (contentbased)_ Object portrait
Matlab create the logo of MATLAB