博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP 图片加水印的方法
阅读量:6947 次
发布时间:2019-06-27

本文共 872 字,大约阅读时间需要 2 分钟。

$dst_path = 'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1597468794,3856954595&fm=80&w=179&h=119&img.JPEG';
 
//创建图片的实例
$dst = imagecreatefromstring(file_get_contents($dst_path));
$name='小强君';
$phone="11111111111";
//打上文字
$font = './AdobeHeitiStd-Regular.otf';//字体
$black = imagecolorallocate($dst, 0x00, 0x00, 0x00);//字体颜色
//参数为 图片,尺寸,旋转角度,像素位置,字体颜色,文字字体,水印文字
imagefttext($dst, 13, 0, 110, 119, $black, $font, $name);
//输出图片
list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
switch ($dst_type) {
case 1://GIF
header('Content-Type: image/gif');
imagegif($dst,"./".$phone.".gif");
break;
case 2://JPG
header('Content-Type: image/jpeg');
imagejpeg($dst,"./".$phone.".jpeg");
break;
case 3://PNG
header('Content-Type: image/png');
imagepng($dst,"./".$phone.".png");
break;
default:
break;
}
 
imagedestroy($dst);

转载于:https://www.cnblogs.com/xiaoqiangjun/p/7687918.html

你可能感兴趣的文章
js 返回并刷新
查看>>
append()与extend()
查看>>
ASPxGridview使用总结(DEVExpress)
查看>>
.NET设计模式(9):桥接模式(Bridge Pattern)
查看>>
极速理解设计模式系列:16.迭代器模式(Iterator Pattern)
查看>>
50个带给你灵感的基于文字的创新Logo设计 - 第一部分
查看>>
恢复右键菜单的“新建”选项
查看>>
Linux面试时遇到的问题
查看>>
【转载】浅谈C#中的延迟加载(1)——善用委托
查看>>
舒服的颜色1
查看>>
Apache HTTP Server 与 Tomcat 的三种连接方式
查看>>
WAMP Server 和IIS 7在Windows中同时运行,更改 Wampserver默认端口的解决方法
查看>>
Memcached
查看>>
C#简单注册表操作实例
查看>>
8天学通MongoDB——第五天 主从复制
查看>>
expect
查看>>
利用...来字符检測(swift)
查看>>
db2 存储过程迁移方法
查看>>
Android 发送短信总结
查看>>
WPF操作ini 文件的读写示例
查看>>