PHP uses the imagecopymerge() function to create a semi-transparent watermark method

jacklove
Release: 2023-03-27 13:48:01
Original
1624 people have browsed it

This video explains how to create a translucent watermark using the imagecopymerge() function through PHP.

Use the imagecopymerge() function to create a translucent watermark for your reference. The specific content is as follows

// Load the image to be watermarked

$im = imagecreatefromjpeg('photo .jpeg');

// First we manually create the watermark image from GD

$stamp = imagecreatetruecolor(100, 70); 
imagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF);
imagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF); 
imagestring($stamp, 5, 20, 20, 'libGD', 0x0000FF);
imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0x0000FF);
Copy after login

// Set the position and size of the watermark image

$marge_right = 10; 
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
Copy after login

// Use 50% Transparency merges watermarks and images

imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50);
Copy after login

// Save the image to a file and release memory

imagepng($im, 'photo_stamp.png');
imagedestroy($im); 
?>
Copy after login

This article explains how to create a semi-transparent watermark in PHP using the imagecopymerge() function. For more information, please Follow php Chinese website.

Related recommendations:

Discuz! Tutorial: How to modify the theme views through a simple php file?

php method of obtaining time

php object-oriented selection sorting example explanation

The above is the detailed content of PHP uses the imagecopymerge() function to create a semi-transparent watermark method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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 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!