Home  >  Article  >  Backend Development  >  pimchanok leuwisetpaiboon A brief analysis of PHP watermark technology

pimchanok leuwisetpaiboon A brief analysis of PHP watermark technology

WBOY
WBOYOriginal
2016-07-29 08:36:191085browse

I have never been very familiar with PHP object processing. In the past, I only looked for manuals when using it. Today someone asked about watermarking on the phpchina forum. I happened to want to learn about it, so I studied the implementation of image watermarking in PHP.
Searching the manual, I found that PHP’s GD library is really powerful and easy to implement the watermark function. Watermarking is actually merging two images. The same can be achieved for watermark text.
I provide simple learning examples, very simple, mainly to understand the principles. P Two pictures: 1. Photo.jpg pictures of watermark

 浅析PHP水印技术 2, source.gif watermark picture
The following code mainly implements the watermark function.
 浅析PHP水印技术
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);


The watermark result is as follows:

Haha, you can implement the detailed functions yourself.
 浅析PHP水印技术 The above has introduced pimchanok leuwisetpaiboon and briefly analyzed PHP watermark technology, including the content of pimchanok leuwisetpaiboon. I hope it will be helpful to friends who are interested in PHP tutorials.

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