PHP imagecopy()与imagecopymerge()图像添加水印
图像添加水印在php中有很多种办法可以实现,他这些功能都是基于php中的GD库的,如果没有开户GD库是不可以使用水印功能的。
imagecopymerge() 函数用于拷贝并合并图像的一部分,成功返回 TRUE ,否则返回 FALSE 。
Windows下开启PHP的GD库支持
找到php.ini,打开内容,找到:
;extension=php_gd2.dll
把最前面的分号“;”去掉,再保存即可,如果本来就没有分号,那就是已经开启了
基本的语法
bool imagecopymerge( resource dst_im, resource src_im, int dst_x,
int dst_y, int src_x, int src_y, int src_w, int src_h, int pct )
参数说明: 参数 说明
dst_im 目标图像
src_im 被拷贝的源图像
dst_x 目标图像开始 x 坐标
dst_y 目标图像开始 y 坐标,x,y同为 0 则从左上角开始
src_x 拷贝图像开始 x 坐标
src_y 拷贝图像开始 y 坐标,x,y同为 0 则从左上角开始拷贝
src_w (从 src_x 开始)拷贝的宽度
src_h (从 src_y 开始)拷贝的高度
pct 图像合并程度,取值 0-100 ,当 pct=0 时,实际上什么也没做,反之完全合并。
当为 pct = 100 时对于调色板图像本函数和 imagecopy() 完全一样
知道了用法,要实现我们的功能就简单了,用下面的代码就可以轻松实现
代码如下 | 复制代码 |
header("Content-type: image/jpeg"); //原始图像 //得到原始图片信息 //水印图像 //水印透明度 //合并水印图片 //输出合并后水印图片 新版本之后imagecopymerge函数几乎不使用了,我们可直接使用imagecopy来生成水印两个函数的功能是完全一样的。 //增加水印 |
一个更好的功能,可以生成缩略并且还可以给图片添加水印
/***
想操作图片
先得把图片的大小,类型信息得到
水印:就是把指定的水印复制到目标上,并加透明效果
缩略图:就是把大图片复制到小尺寸画面上
***/
代码如下 | 复制代码 |
class ImageTool { $dinfo['height']); |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software