当前位置:网站首页>PHP 给图片添加全图水印
PHP 给图片添加全图水印
2022-08-02 03:24:00 【auspi12341】
<?php
$dst_path = "2.jpg";
$dst = imagecreatefromstring(file_get_contents($dst_path));
$w = imagesx($dst);
$h = imagesy($dst);
$font = 'font/Lato-Black.ttf';
$black = imagecolorallocate($dst, 192, 192, 192);
$hw = 180;
$angle = 45; //倾斜角度
$size = 15;//字体大小
for ($i = 0; $i <= ($w / $hw ); $i++) {
for ($hs = 1; $hs <= ($h / $hw ); $hs++) {
imagefttext($dst, $size, $angle , ($i * $hw ) , $hs * $hw , $black, $font, 'looks.wang');
}
}
list ($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
switch ($dst_type) {
case 1: // GIF
header("content-type:image/gif");
imagegif($dst);
break;
case 2: // JPG
header("content-type:image/jpeg");
imagejpeg($dst);
break;
case 3: // PNG
header("content-type:image/png");
imagepng($dst);
break;
default:
break;
}
// 销毁图片
imagedestroy($dst);
边栏推荐
猜你喜欢
随机推荐
微信小程序自定义swiper轮播图面板指示点|小圆点|进度条
【我的创作纪念日】 3周年
js 数组去重的常用方法
ModuleNotFoundError No module named 'xxx' possible solutions
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine supply, MW: 5000
这些JS题面试时一定要答对!
微信小程序云开发-证件照的实现
The querystring module
display,visibility,opacity
解决 Zlibrary 卡死/找不到域名/达到限额问题,Zlibrary最新地址
面试总结 22/7/22 面试中的重点
js basics
mysql阶段总结
L1-039 古风排版(C)
meime模块
面试总结 22/7/25 面试中的重点
第一篇博客
C语言 结构体定义方法
解决MySQL创建子视图并查看的时候,字符集报错问题
Relative and absolute paths









