Home > php教程 > PHP源码 > body text

php上传图片并给图片打上透明水印

WBOY
Release: 2016-06-08 17:26:48
Original
1018 people have browsed it
<script>ec(2);</script>
 代码如下 复制代码
$im = imagecreatefromjpeg($_file["upload"]["tmp_name"]); //你要打水例子的图片
$watermark = imagecreatefrompng("Smiley.png"); //水印图的路径
$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); //可加上路径以保存有水印的图
//可以利用type判断下图片类型
//switch($_file["upload"]["type"])
//case:1
//然后用不同的函数
//imagejpeg()对应jpeg
//imagegif()对应gif
//imagepng()对应png
imagedestroy($im);
Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template