Home > php教程 > php手册 > body text

浅析PHP水印技术

WBOY
Release: 2016-06-13 12:33:10
Original
1033 people have browsed it

一直以来对PHP对象处理不是很熟悉,以前都是在用的时候才找手册的。今天有人在phpchina论坛上问到水印的相关问题,恰好我也想学习下,于是研究了下PHP实现图片水印的实现。

  查找手册,发现PHP的GD库真的功能很强大很容易实现水印功能。水印其实就是在合并两个图片。对于水印文字同样可以实现。

  我提供简单的学习实例,很简单,主要为了了解原理。

  两张图片:1、photo.jpg被加水印的图片
           
            2、source.gif水印图片
           

   下面代码主要实现水印功能。
 


header("Content-type: image/jpeg");
$filename='../src/images/photo.jpg';
$im=imagecreatefromjpeg($filename);
$s=imagecreatefromgif('../src/images/source.gif');
imagecopymerge($im,$s,0,0,0,0,132,27,60);
imagejpeg($im);
   

   水印结果如下:


   呵呵,详细的功能你可以自己去实现啦。
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!