20,359
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en">
<head>
<div id='wx_pic' style='margin:0 auto;display:none;'>
<img src='1.png' />
</div>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>图片自动加水印程序</title>
<link type="text/css" rel="stylesheet" href="frozen.css" />
<style>
body{color:#a6a6a6; font-size:16px; padding-top:45px;}
body b{color: #00A5E3}
body>a{display:none;}
h2.title {line-height: 45px;font-size: 20px;color: #FF0000;position: fixed;top: 0;height: 45px;-webkit-box-sizing: border-box;width: 100%;z-index: 9999;background-color: #f8f9fa;text-align:center;}
.pr5{padding-bottom:45px;}
.pr5 p{margin-bottom:5px;}
.ui-list{background-color:#f8f9fa;padding-bottom:5px}
#mcover{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.7);display:none;z-index:20000;}
#mcover img{position:fixed;right: 18px;top:5px;width:260px;height:180px;z-index:20001;}
</style>
</head>
<body ontouchstart="">
<h2 class="title ui-border-b">图片自动加水印程序</h2>
<div class="wrapper">
<img src="icon2.jpg" width="50%" style="margin:80px 25% 80px 25%;"/>
<div class="ui-form">
<div class="file-box">
<form action="up.php" method="post" enctype="multipart/form-data">
<div class="ui-form-item ui-border-b">
<label for="#">输入姓名</label>
<input type="text" name="name1" placeholder="最多显示10个字"/>
<label for="#">头像jpg</label>
<input type="file" name="file" value="限jpg图片"/>
</div>
<br />
<br />
<br />
<div class="ui-btn-wrap">
<button class="ui-btn-lg ui-btn-danger">下一步</button>
</div>
</form>
</div>
</div>
<script type="text/javascript" src="../zepto.min.js"></script>
<script type="text/javascript" src="../frozen.js"></script>
</body>
</html>
<?php
/******************************************************************************
******************************************************************************/
//上传文件类型列表
$uptypes=array(
'image/jpg',
'image/jpeg',
'image/png',
'image/pjpeg',
'image/gif',
'image/bmp',
'image/x-png'
);
$max_file_size=2000000;
$destination_folder="";
$imgpreview=1;
$imgpreviewsize=1/2;
?>
<?php
$xingbie = $_GET['xingbie']?$_GET['xingbie']:"2.jpg";
$src_img = $xingbie;
list($src_w, $src_h) = getimagesize($src_img);
$dst_h=680;
$dst_w=742;
$dst_scale = $dst_h/$dst_w;
$src_scale = $src_h/$src_w;
if($src_scale>=$dst_scale)
{
$w = intval($src_w);
$h = intval($dst_scale*$w);
$x = 0;
$y = ($src_h - $h)/3;
}
else
{
$h = intval($src_h);
$w = intval($h/$dst_scale);
$x = ($src_w - $w)/2;
$y = 0;
}
$source=imagecreatefromjpeg($src_img);
$croped=imagecreatetruecolor($w, $h);
imagecopy($croped,$source,0,0,$x,$y,$src_w,$src_h);
$scale = $dst_w/$w;
$target = imagecreatetruecolor($dst_w, $dst_h);
$final_w = intval($w*$scale);
$final_h = intval($h*$scale);
imagecopyresampled($target,$croped,0,0,0,0,$final_w,$final_h,$w,$h);
$timestamp = time();
imagejpeg($target, "$timestamp.jpg");
imagedestroy($target);
$dst_path = 'toutuaq1.jpg';
$src_path = "$timestamp.jpg";
$dst = imagecreatefromstring(file_get_contents($dst_path));
$src = imagecreatefromstring(file_get_contents($src_path));
list($src_w, $src_h) = getimagesize($src_path);
imagecopymerge($dst, $src, 0, 0, 0, 0,$src_w, $src_h, 100);
$timestamp1 = time();
imagejpeg($dst, "$timestamp1.jpg");
imagedestroy($dst);
$name = $_GET['name']?$_GET['name']:"图片水印";
$a1 = mb_substr($name,0,10,'utf-8');
header("content-type:image/jpeg");
$im = imagecreatetruecolor(742, 989);
$bg = imagecreatefromjpeg("$timestamp1.jpg");
imagecopy($im,$bg,0,0,0,0,742,989);
imagedestroy($bg);
$black = imagecolorallocate($im, 0, 0, 0);
$text1 = $a1;
$font = 'fh.ttf';
imagettftext($im, 30, 0, 220, 660, $black, $font, $text1);
list($dst_w, $dst_h, $dst_type) = getimagesize("toutuaq1.jpg");
switch ($dst_type) {
case 1://GIF
header('Content-Type: image/gif');
imagegif($im);
break;
case 2://JPG
header('Content-Type: image/jpeg');
imagejpeg($im);
break;
case 3://PNG
header('Content-Type: image/png');
imagepng($im);
break;
default:
break;
}
$timestamp2 = time();
imagejpeg($im,"$timestamp2.jpg");
imagedestroy($im);
?>
<!doctype html>
<?php
/******************************************************************************
参数说明:
$max_file_size : 上传文件大小限制, 单位BYTE
$destination_folder : 上传文件路径
$watermark : 是否附加水印(1为加水印,其他为不加水印);
使用说明:
1. 将PHP.INI文件里面的"extension=php_gd2.dll"一行前面的;号去掉,因为我们要用到GD库;
2. 将extension_dir =改为你的php_gd2.dll所在目录;
******************************************************************************/
//上传文件类型列表
$uptypes=array(
'image/jpg',
'image/jpeg',
'image/png',
'image/pjpeg',
'image/gif',
'image/bmp',
'image/x-png'
);
$max_file_size=2000000; //上传文件大小限制, 单位BYTE
$destination_folder=""; //上传文件路径
$imgpreview=1; //是否生成预览图(1为生成,其他为不生成);
$imgpreviewsize=1/2; //缩略图比例
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图片上传</title>
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<style type="text/css">
<!--
body
{
font-size: 9pt;
}
input
{
background-color: #66CCFF;
border: 1px inset #CCCCCC;
}
-->
</style>
<style type="text/css">
body{ font-size:14px;}
input{ vertical-align:middle; margin:0; padding:0}
.file-box{ position:relative;width:340px}
.txt{ height:22px; border:1px solid #cdcdcd; width:180px;}
.btn{ background-color:#FFF; border:1px solid #CDCDCD;height:24px; width:70px;}
.file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }
</style>
</head>
<body>
<div class="file-box">
<form action="" method="post" enctype="multipart/form-data">
<input type='text' name='textfield' id='textfield' class='txt' />
<input type='button' class='btn' value='浏览...' />
<input type="file" name="upfile" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />
<input type="submit" name="submit" class="btn" value="上传" />
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>图片自动生成程序</title>
<link type="text/css" rel="stylesheet" href="frozen.css" />
<style>
body{color:#a6a6a6; font-size:16px; padding-top:45px;}
body b{color: #00A5E3}
body>a{display:none;}
h2.title {line-height: 45px;font-size: 20px;color: #FF0000;position: fixed;top: 0;height: 45px;-webkit-box-sizing: border-box;width: 100%;z-index: 9999;background-color: #f8f9fa;text-align:center;}
.pr5{padding-bottom:45px;}
.pr5 p{margin-bottom:5px;}
.ui-list{background-color:#f8f9fa;padding-bottom:5px}
#mcover{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.7);display:none;z-index:20000;}
#mcover img{position:fixed;right: 18px;top:5px;width:260px;height:180px;z-index:20001;}
</style>
</head>
<body>
<h2 class="title ui-border-b"><a href="/">长按下图保存图片</a></h2>
<br/>
<?php
$name1 = $_POST['name1'];
$xingbie = $_FILES["file"]["name"];
$file = $_FILES['file'];//得到传输的数据
//得到文件名称
$name = $file['name'];
$type = strtolower(substr($name,strrpos($name,'.')+1)); //得到文件类型,并且都转化成小写
$allow_type = array('jpg','jpeg','gif','png');
//定义允许上传的类型//判断文件类型是否被允许上传
if(!in_array($type, $allow_type)){
//如果不被允许,则直接停止程序运行
return ;}
//判断是否是通过HTTP POST上传的
if(!is_uploaded_file($file['tmp_name'])){
//如果不是通过HTTP POST上传的
return ;}
$upload_path = "";
//上传文件的存放路径
//开始移动文件到相应的文件夹
if(move_uploaded_file($file['tmp_name'],$upload_path.$file['name'])){
}else{
}
?>
<div class="wrapper">
<img src="toutu.php?name=<?php echo $name1?>&xingbie=<?php echo $xingbie?>" width="100%"/>
</div>
<script type="text/javascript" src="../zepto.min.js"></script>
<script type="text/javascript" src="../frozen.js"></script>
</body>
</html>