当前位置:网站首页>PHP generates text and image watermarks
PHP generates text and image watermarks
2022-07-27 10:35:00 【Luckinman】
One 、 Material preparation
A computer , A picture , A font library , Oh

Where can I find the font library ?C disc ——Fonts Folder


Just search Microsoft YaHei
Two 、 Code implementation
<?php
// Configure picture information
$src="cat.jpg";
// Get picture information
$info=getimagesize($src);
// Get the type of picture by the number of the image
$type=image_type_to_extension($info[2],false); //.jpeg If you don't want to point Just false fall
// Create an image in memory that is the same as our image type
$fun="imagecreatefrom{$type}";
$image=$fun($src);
// Set the path of the font
$font="msyhbd.ttc";
// Fill in our watermark
$content=" I love you China ";
// Set the color and transparency of the font
$col=imagecolorallocatealpha($image,255,255,255,50);
// Write words
imagettftext($image,20,0,20,30,$col,$font,$content);
// Browser output
header('Content-type:'.$info['mime']);
$func = "image{$type}";
$func($image);
// Save the picture
$func($image,'save.'.$type);
// Destroy picture
imagedestroy($image);
?>3、 ... and 、 Run locally

边栏推荐
- 多点双向重发布和路由策略
- Multipoint bidirectional republication and routing strategy
- Beijing publicized the spot check of 8 batches of children's shoes, and qierte was listed as unqualified
- Establishment of NFS server
- Word2vec principle and application and article similarity (recommended system method)
- 游戏玩家问题
- Xiandai 004
- 【Liunx】安装Redis
- Discussion on a problem
- Mysql database experiment training 5, data query YGGL database query (detailed)
猜你喜欢

Uninstall cuda11.1
[email protected] @Eslint loader / index. JS) "/>Eslint's error message module error (from./node_modules/ [email protected] @Eslint loader / index. JS)

异构计算技术分析

文件上传漏洞绕过方法

Oracle查看硬解析

warning: remote HEAD refers to nonexistent ref, unable to checkout报错信息

Oracle view hard parsing

Beijing publicized the spot check of 8 batches of children's shoes, and qierte was listed as unqualified

免费 DIY 之旅问题

【Liunx】MariaDB/MySQL定时全量备份脚本及数据恢复
随机推荐
分享机器学习笔记(PDF版)+实战项目(数据集+代码)
Oracle resizing data files
ORACLE 11g手动内存管理
FTP 服务器
邮件服务器
颜值爆表!推荐两款JSON可视化工具,配合Swagger使用真香
ctf (hardrce)
Discussion on a problem
分布式块设备复制:客户端
wind10配置adb命令
Oracle 11g manual memory management
Matlab create text cloud
es6的foreach与some的循环遍历
hdu5288(OO’s Sequence)
Matlab底层源代码实现图像的中值滤波(用于消除图像上一些杂点)
让人深思:句法真的重要吗?邱锡鹏组提出一种基于Aspect的情感分析的强大基线...
Oracle查看硬解析
线代003
Matlab draws the system response under different damping
【Liunx】安装MySQL