简单的php图片上传自动给图片加水印
May 25, 2016 pm 04:46 PM给自己网站上的图片添加水印,在图片上留下属于自己的信息,这有两个好处:一是宣传自己的品牌,二是就算带图片的文章被转载了,也会自动的留下了版权。
本文主要实现了php图片上传自动给图片加水印,在下篇中我会给出用php添加文字水印的代码。
php给图片加水印其实很简单,没有想象的那么神奇,就是利用了php里面的一个GD库。说起GD库,其实就是php里面一个专门用于处理图片有关的扩展,比如我们熟悉的验证码、生成缩略图,包括今天所说的php给图片加水印都是要有GD库的支持。
提示:新安装的php环境,可能需要开启GD库,开启方法:打开php.ini,去掉extension=php_gd2.dll前面的“;”然后重启apache/iis即可。
实现并不复杂,核心代码还不到20行,主要是掌握几个函数就行了。
实现源码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
给图片添加水印除了用基础的GD库实现,其实还可以ImageMagick这个工具,它的功能更强大,不过一般没多大需求,就用上面这个代码了。
永久地址:
转载随意~请带上教程地址吧^^

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to disable taskbar thumbnail preview in Win11? Turn off the taskbar icon display thumbnail technique by moving the mouse

How to customize folder thumbnails in Windows 11 22H2

How to display thumbnails in Vscode_How to display thumbnails in Vscode

Automatic thumbnail generation using JavaScript

How to display thumbnails on USB drive

How to implement image scrolling and thumbnail preview in Vue?

Detailed explanation of the steps to generate thumbnails in PHP

How to insert a table in a Powerpoint presentation
