Home  >  Article  >  Web Front-end  >  PHP code to upload pictures and put transparent watermark on pictures_javascript skills

PHP code to upload pictures and put transparent watermark on pictures_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:25:371154browse
Copy code The code is as follows:

$im = imagecreatefromjpeg($_file["upload"]["tmp_name "]); //You want to draw the picture of the water example
$watermark = imagecreatefrompng("Smiley.png"); //The path of the watermark image
$im_x = imagesx($im);
$ im_y = imagesy($im);
$w_x = imagesx($watermark);
$w_y = imagesy($watermark);
imagecopy($im,$watermark ,$im_x-$w_x,$ im_y-$w_y,0,0,$w_x,$w_y);
imagejpeg($im); //You can add a path to save the watermarked image
//You can use type to determine the image type
//switch($_file["upload"]["type"])
//case:1
//Then use different functions
//imagejpeg() to correspond to jpeg
//imagegif() corresponds to gif
//imagepng() corresponds to png
imagedestroy($im);
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