当前位置:网站首页>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

边栏推荐
- Mathematical reasoning: five couples get together and shake hands when they meet
- Sound processing - Mel frequency cepstrum coefficient (MFCC)
- 语音数据采集-实时语音数据可视化
- Matlab create text cloud
- es6 class 继承的重点
- [Linux] install MySQL
- gyp ERR! configure error. gyp ERR! stack Error: gyp failed with exit code: 1
- 简单几步教您实现为工业树莓派共享网络
- Redis数据结构分析(二)
- 阿里邮箱web端登录转圈的处理
猜你喜欢

NFS 服务器的搭建

家庭琐事问题

hdu5288(OO’s Sequence)

Basic statement of database operation

NVIDIA geforce experience login error: the verifier failed to load. Please check your browser settings, such as the advertisement interceptor (solution)

Word2vec principle and application and article similarity (recommended system method)

服务器访问速度

File upload vulnerability bypass method

游戏玩家问题

Metasploit-永恒之蓝攻击
随机推荐
Pytorch installation (very detailed)
北京公示儿童鞋抽查 8组批产品不合格琪尔特登榜
How to turn off the application of computer self startup
A brief introduction to R language pipeline symbols (% >%) and placeholders (.)
Understanding of batchnorm2d() function in pytorch
Key points of ES6 class inheritance
Ubuntu and MySQL quick start tutorial
邮件服务器
flask_restful中的输出域(Resource、fields、marshal、marshal_with)
文件上传漏洞相关
Matlab的不同进制转换
Sorting out some open source projects of speech recognition
Redis数据结构分析(二)
程序的翻译和执行,从编辑、预处理、编译、汇编、链接到执行
Establishment of NFS server
Understanding and code implementation of Se (sequence and exception) module
Voice data acquisition - real time voice data visualization
语音数据采集-实时语音数据可视化
Pyautogui realizes automatic office -rpa small case
Metaspolit