对图片进行操作,常用的就是上传及对图片进行裁剪,生成缩略图等
/// <summary>
/// jqueryUpImg 图片上传及裁剪
/// </summary>
public class jqueryUpImg : IHttpHandler
{
private string urlPath = "";
对图片进行操作,常用的就是上传及对图片进行裁剪,生成缩略图等
/// <summary>
/// jqueryUpImg 图片上传及裁剪
/// </summary>
public class jqueryUpImg : IHttpHandler
{
private string urlPath = "";
参考头像截图,js、css文件可以网上下载
前台代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>上传大小不变图片缩放的切图</title>
<link href="Css/CutPhoto.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="JS/jquery.easydrag.js" type="text/javascript"></script>
<script src="JS/CutPhoto.js" type="text/javascript"></script>
<script type="text/javascript">
function Step1() {
$("#Step2Container").hide();
$("#savephoto").hide();
}
function Step2() {
$("#Step2Container").hide();
$("#Step1Container").hide();
$("#savephoto").show();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>如何用javascript JQuery 判断图片是否存在</title>
返回值为200的时候,为图片能正常显示
private int GetUrlError(string curl) {
int num = 200;
if (this.method == 1) {
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(new Uri(curl));
上传图片时需要将图片进行按照宽度缩放,直接调用方法就可以上传图片
/// <summary>
/// 图片按宽带等比缩放
/// </summary>
/// <param name="fromFile">原图Stream对象</param>
/// <param name="savePath">缩略图存放地址</param>
/// <param name="targetWidth">指定的最大宽度</param>
public static void ZoomAuto(System.IO.Stream fromFile, string savePath, System.Double targetWidth)
{
//创建目录
string dir = Path.GetDirectoryName(savePath);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
郑德才弹出层测试
</title>
</head>
<body style="padding: 0px; background-color: #3399cc;">
<div id="ads_14" style="font-family: verdana,sans-serif; width:230px; height:200px; height:0px; padding:0px; margin:0px; right:2; bottom:2;