To add watermarks to images in PHP, we need to use many functions, such as imagecreatefromjpeg, imagecreatefrompng, getimagesize and other functions. These are all functions belonging to the PHP GD library, so we must open the GD library in php.ini Only then can PHP use these functions to generate image watermarks.
To implement the watermark function, we mainly rely on these functions
1.imagecreatefromjpeg // Open JPG image 2.imagecreatefromgif // Open GIF image
3.imagecreatefrompng // Open PNG image
4.imagecreatefromwbmp // Open WBMP image (less commonly used)
5.getimagesize // Get image size information
6.imagecopymerge // Integrate multiple images (the main function of adding watermarks)
7.imagejpeg // Save JPG image
8.imagegif // Save GIF image
9.imagepng // Save PNG image
代码如下 | 复制代码 |
|
Currently supports jpg, gif, png and other image formats.
Usage example:
The code is as follows | Copy code | ||||||||
{ echo '' ; } else { echo ''; } The following demonstrates a complete full watermark adding function
Related labels:
source:php.cn
Previous article:php mysql string replacement method_PHP tutorial
Next article:Analysis of SQL injection vulnerability drag library principle for sql security_PHP tutorial
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
Latest Articles by Author
Latest Issues
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|