当前位置:网站首页>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);
边栏推荐
猜你喜欢
随机推荐
我的小笔记 =》其他东东
Phospholipid-polyethylene glycol-targeted neovascularization targeting peptide APRPG, DSPE-PEG-APRPG
【我的创作纪念日】 3周年
npm and package.json
配置mmdet来训练Swin-Transformer之一配置环境
C语言入门小游戏—三子棋
js基础知识
display,visibility,opacity
Guangzhou Huawei Interview Summary
C语言的变长数组
如何计算地球上两点的距离(附公式推导)
微信小程序云开发如何将页面生成为pdf?
微信小程序云开发之券码领取,怎么防止用户领取到相同的数据?
Error in render: “TypeError: Cannot read properties of null (reading ‘0‘)“ 报错解决方案
C语言 0长度数组/柔性数组
每日五道面试题 2022/7/27
如何根据地图上的两个坐标点来确定方向
C语言 十六进制整数字符串转十进制整数
5.19今日学习
面试总结 22/7/25 面试中的重点









