Home > Backend Development > PHP Tutorial > PHP watermarking code (supports translucent and transparent watermarking, supports png transparent background)_PHP tutorial

PHP watermarking code (supports translucent and transparent watermarking, supports png transparent background)_PHP tutorial

WBOY
Release: 2016-07-21 15:14:03
Original
826 people have browsed it

Copy code The code is as follows:

//Original image
$dst = "/upload/20120914/20120914040740- 0.jpg"; //Note that the image path must be correct
//Get the original image information
$dst_info = getimagesize($dst);
switch ($dst_info[2])
{
case 1:
$dst_im =imagecreatefromgif($dst);break;
case 2:
case 3:
$dst_im = imagecreatefrompng($dst);break;
case 6:
$dst_im =imagecreatefromwbmp($dst);break;
default:
die("Unsupported file type 1");exit;
                                                                                                                                                                                      $src_info[2])
                                                                                                                                          
case 3:
$src_im =imagecreatefrompng($src);break;
case 6:
$src_im =imagecreatefromwbmp($src);break;
default:
        die( "Unsupported file type 1");exit;
                                                                                                               dst_im,$src_im,$dst_info[0]-$src_info[0]-10,$dst_info[1]-$src_info[1]-10,0,0,$src_info[0],$src_info[1],$ alpha);

//How to support the transparency of png itself
imagecopy($dst_im,$src_im,$dst_info[0]-$src_info[0]-10,$dst_info[1]-$src_info [1]-10,0,0,$src_info[0],$src_info[1]);

//Save the picture
switch ($dst_info[2]){
case 1 :
imagegif($dst_im,$dst);break;
case 2:
imagejpeg($dst_im,$dst);break;
case 3:
imagepng($dst_im,$ dst);break;
case 6:
imagewbmp($dst_im,$dst);break;
default:
die("Unsupported file type 2");exit;
}
imagedestroy($dst_im);
imagedestroy($src_im);






http://www.bkjia.com/PHPjc/326350.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/326350.html
TechArticleCopy code The code is as follows: //Original image $dst = "/upload/20120914/20120914040740-0.jpg" ; //Pay attention to the correct image path //Get the original image information $dst_info = getimagesize($dst); s...

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