Home  >  Article  >  Backend Development  >  The implementation process of adding watermark to pictures in php

The implementation process of adding watermark to pictures in php

黄舟
黄舟Original
2017-08-21 17:41:293129browse

Share a PHP class that adds watermarks to images. It supports watermark images. The calling method is send( strimg filename ). This method has a function that can be omitted. In the case of omission, the path and name of the saved image will be the same as the original one. , if you need to save it as an exception picture, just provide the path and name of the picture to be saved here
Exception, there is another method, show(); This method is used to display the watermarked picture
This method can Call it alone, but you must call the send() method first, or you can call it continuously: $img->send()->show();

Step 1: Download what we need for this lesson PHP class for adding watermarks to images: http://www.php.cn/xiazai/leiku/761

Step 2: After the download is complete, find the PHP class file and unzip it to the local server. Create a new php file!

Step 3: We call this class in this new file and instantiate this class:

<?php
include_once "jiashuiyin.php";//引入类文件
$img = new Images;//然后实例化类
//然后提供图片:
$oldimg = &#39;D:/phpStudy/WWW/myclass/timg.jpg&#39;;//原图片路径及名称
$newing = "D:/phpStudy/WWW/myclass/shuiyin.jpg";//水印图片路径及名称
$img->imgpath($oldimg, $newing, $WeiZhi = 9);//$WeiZhi 水印位置

print_r($img->send());//开始加水印
?>

Here we print out the location information of the picture:

The implementation process of adding watermark to pictures in php

Then find the original picture:

The implementation process of adding watermark to pictures in php

The above is the detailed content of The implementation process of adding watermark to pictures in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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