分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

PHP 图片加水印的方法

发布时间:2023-09-06 01:18责任编辑:彭小芳关键词:PHP
$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="13161884078";
//打上文字
$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);

PHP 图片加水印的方法

原文地址:http://www.cnblogs.com/xiaoqiangjun/p/7687918.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved