仿MOP、ChinaRen、Csdn在线切割图片设置头像功能

介绍了一个使用ASP、JavaScript和Ironsoft组件实现的图片裁剪工具,该工具支持自定义裁剪区域大小及位置,并实时预览裁剪效果。

用到的组件是铁匠组件

页面:2个asp文件,一个Css文件,一个Js文件

Index.asp代码:

<%
Imgw=75
Imgh=75
ImgBg="images/bg75.gif"
ImgBgw=Imgw+16
ImgBgh=Imgh+17
ImgSc=1
minw=30
minh=30
%>
<html>  
<head>
<title></title>
<link href="images/wpager.css" rel="stylesheet" type="text/css">
<script src="images/ok.js" type="text/javascript"></script>
<style type="text/css">
#cropDiv {
 width:<%=Imgw%>px;
 height:<%=Imgh%>px;
}
#resultDiv {
 width:<%=Imgw%>px;
 height:<%=Imgh%>px;
 background:url('<%=ImgBg%>');
}
</style>
</head>
<body>
<%
ImgPath="images/test.jpg"

Set IronDraw = Server.CreateObject("Ironsoft.DrawPic")
IronDraw.LoadFromFile Server.Mappath(ImgPath)
picw=IronDraw.width
pich=IronDraw.height
Set IronDraw=Nothing

if (picw<Imgw and pich>Imgh) or (picw<Imgw and pich<Imgh and picw<pich) then
 corpw=picw
 corph=picw/ImgSc
 maxw=picw
 maxh=corph
elseif (pich<Imgh and picw>Imgw) or (picw<Imgw and pich<Imgh and picw>pich) then
 corph=pich
 corpw=pich*ImgSc
 maxw=corpw
 maxh=pich
else
 corpw=Imgw
 corph=Imgh
 maxw =500
 maxh =500
end if
%>
<form action="SetSave.asp" method=post target=_blank><input id="btnImgInfo" name="xy" style="width:600"> <input type=submit value="查看效果"><input name="picfile" type=hidden value="<%=ImgPath%>"></form>
<div style="position:absolute;top:50; left:10;width:<%=ImgBgw%>;height:<%=ImgBgh%> ;background:url('<%=ImgBg%>');">
 <div style="position:absolute;top:8; left:8"><div id="resultDiv"><img src="<%=ImgPath%>" id="resultPic"></div></div>
</div>
<div id="bgDiv"><img src="<%=ImgPath%>" style="filter:alpha(opacity:50);"></div>
<div id="picDiv" style="clip:rect(0,0,0,0);"><img src="<%=ImgPath%>"></div>
<div id="cropDiv" style="width:<%=corpw%>px;height:<%=corph%>px">
<table height="100%" width="100%" cellspacing="0" cellpadding="0"><tr><td height="100%" width="100%"><div id="cropDrag"></div></td></tr></table>
<div id="topLeft" class="border"></div>
<div id="topRight" class="border"></div>
<div id="bottomLeft" class="border"></div>
<div id="bottomRight" class="border"></div>
</div>

<script language="javascript">
 picw = <%=picw%>;
 pich = <%=pich%>;
 minw = <%=minw%>;
 minh = <%=minh%>;

 maxw = <%=maxw%>;
 maxh = <%=maxh%>;
 
    var objbtnImgInfo ;
 objbtnImgInfo = document.getElementById("btnImgInfo") ;
  
 function fnWritePos(intLeft,intTop,intw,inth,intx,inty) {
 objbtnImgInfo.innerText = intLeft +","+ intTop  +","+ intw +","+ inth +","+ intx +","+ inty;
 }

  var divCrop = $("cropDiv");
  var divCropDrag = $("cropDrag");
  var divPic = $("picDiv");
  var divRes = $("resultDiv");
  var picRes = $("resultPic");
  
  var topLeft = $("topLeft");
  var topRight = $("topRight");
  var bottomLeft = $("bottomLeft");
  var bottomRight = $("bottomRight");
  
  
  divCrop.style.left = (divPic.offsetLeft) + "px";
  divCrop.style.top = (divPic.offsetTop) + "px";

  var constrain = <%=ImgSc%>;
  
  function setClipPos() {
   var t = (divPic.offsetTop);
   var l = (divPic.offsetLeft);
   var top = divCrop.offsetTop-t;
   var right = divCrop.offsetLeft+divCrop.offsetWidth-l;
   var bott = divCrop.offsetTop+divCrop.offsetHeight-t;
   var left = divCrop.offsetLeft-l;
   var r = {t:top,r:right,b:bott,l:left};
   var rect = "rect("+r.t+","+r.r+","+r.b+","+r.l+")";
   if (right>picw)
   {
   if (picw>pich)
   {
   right=picw;left=left-2;
   }else
   {
   right=right;left=left-2;
   }
   }
   if (bott>pich)
   {
   if (picw<pich)
   {
   bott=pich;top=top-2;
   }else
   {
   bott=bott;top=top-2;
   }
   }
   if (left<0) left=0;
   if (top <0) top=0;
   fnWritePos(left,top,divCrop.offsetWidth,divCrop.offsetHeight,right,bott);   
   
   divPic.style.clip = rect;
   
   var sc = <%=Imgh%>/divCrop.offsetHeight;

   picRes.style.zoom = (sc*100)+"%";
   
   divRes.scrollTop = r.t*sc;
   divRes.scrollLeft = r.l*sc;
   
  }
  
  Resize.init(topLeft, divCrop, 0, constrain, minw, minh, maxw, maxh);
  Resize.init(bottomLeft, divCrop, 1, constrain, minw, minh, maxw, maxh);
  Resize.init(topRight, divCrop, 2, constrain, minw, minh, maxw, maxh);
  Resize.init(bottomRight, divCrop, 3, constrain, minw, minh, maxw, maxh);
  divCrop.onResize = function(x,y, mousex, mousey) {
   var t = parseInt(divPic.offsetTop);
   var l = parseInt(divPic.offsetLeft);
   if (x + divCrop.offsetWidth > l + divPic.offsetWidth) {
    x = l + divPic.offsetWidth - divCrop.offsetWidth;
    divCrop.style.left = x + "px";
   }
   if (x < l) {
    x = l;
    divCrop.style.left = x + "px";
   }
   if (y + divCrop.offsetHeight > t + divPic.offsetHeight) {
    y = t + divPic.offsetHeight - divCrop.offsetHeight;
    divCrop.style.top = y + "px";
   }
   if (y < t) {
    y = t;
    divCrop.style.top = y + "px";
   }
   //02-24
   if (divCrop.offsetHeight > divPic.offsetHeight) {
    divCrop.style.height = divPic.offsetHeight-7 + "px";
   }
   setClipPos();
  }
  
  Drag.init(divCropDrag, divCrop);
  divCrop.onDrag = function(x,y, mousex, mousey) {
   var t = parseInt(divPic.offsetTop);
   var l = parseInt(divPic.offsetLeft);
   if (x + divCrop.offsetWidth > l + divPic.offsetWidth) {
    x = l + divPic.offsetWidth - divCrop.offsetWidth;
   }
   if (x < l) {
    x = l;
   }
   if (y + divCrop.offsetHeight > t + divPic.offsetHeight) {
    y = t + divPic.offsetHeight - divCrop.offsetHeight;
   }
   if (y < t) {
    y = t;
   }
   divCrop.style.left = x + "px";
   divCrop.style.top = y + "px";
   setClipPos();
  }
  setClipPos();

</script>
</body>
</html>

 

 SetSave.asp代码

<%
file1="1"
response.write request("xy")
xy=split(request("xy"),",",-1,1)

Set IronDraw = Server.CreateObject("Ironsoft.DrawPic")
IronDraw.LoadFromFile Server.Mappath(request("picfile"))   '装载图片,也要记住有权限的问题
IronDraw.Cut  cint(xy(0)),cint( xy(1)),cint(xy(4)),cint( xy(5)) '大于原大,添加空白
IronDraw.SaveAS Server.Mappath(file1&".jpg")  '保存图片:图片的全路径,记住有权限的问题,应该把它保存在有权限的目录下面
'IronDraw.ShowImage       '在页面中显示图片
Set IronDraw = Nothing
response.Write "<img src="&file1&".jpg>"

%>

 

wpager.css代码

/*制作头像*/

#bgDiv,#picDiv {
 position:absolute;
 top:50px;
 left:200px;
 text-align:center;
 z-index:5;
 padding:0;
}
#cropDiv {
 position:absolute;
 z-index:2000;
 padding:0;
 border: 1px solid #FF0000;
}
#cropDiv .border{
 position:absolute;
 width:5px;
 height:5px;
 overflow:hidden;
 background-color:#FF0000;
 z-index:3001;
 padding:0;
}
#topLeft{
left:0px;top:0px;cursor:NW-resize;
}
#topRight{
right:0px;top:0px;cursor:NE-resize;
}
#bottomLeft{
left:0px;bottom:0px;cursor:SW-resize;
}
#bottomRight{
right:0px;bottom:0px;cursor:SE-resize;
}
#resultDiv {
 margin:0;
 overflow:hidden;
 padding:0
}
#cropDrag {
 position:absolute;
 left:0px;
 top:0px;
 width:100%;
 height:100%;
 cursor:move;
 z-index:3000;
}
/* Topaz End */

 

ok.js代码

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}

//-------------------------------------------------------------------
//Drag Object
var Drag={
 "obj":null,
 "init":function(a, aRoot){
   a.onmousedown=Drag.start;
   a.root = aRoot;
   if(isNaN(parseInt(a.root.style.left)))a.root.style.left="0px";
   if(isNaN(parseInt(a.root.style.top)))a.root.style.top="0px";
   a.root.onDragStart=new Function();
   a.root.onDragEnd=new Function();
   a.root.onDrag=new Function();
  },
 "start":function(a){
   window.event.cancelBubble = true;
   var b=Drag.obj=this;
   a=Drag.fixE(a);
   var c=parseInt(b.root.style.top);
   var d=parseInt(b.root.style.left);
   b.root.onDragStart(d,c,a.clientX,a.clientY);
   b.lastMouseX=a.clientX;
   b.lastMouseY=a.clientY;
   document.onmousemove=Drag.drag;
   document.onmouseup=Drag.end;
   return false;
  }, 
 "drag":function(a){
   a=Drag.fixE(a);
   var b=Drag.obj;
   var c=a.clientY;
   var d=a.clientX;
   var e=parseInt(b.root.style.top);
   var f=parseInt(b.root.style.left);
   var h,g;
   h=f+d-b.lastMouseX;
   g=e+c-b.lastMouseY;
   b.root.style.left=h+"px";
   b.root.style.top=g+"px";   
   b.lastMouseX=d;
   b.lastMouseY=c;
   b.root.onDrag(h,g,a.clientX,a.clientY);
   return false;
  },
 "end":function(){   
   document.onmousemove=null;
   document.onmouseup=null;
   Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top));
   Drag.obj=null;
  },
 "fixE":function(a){
   if(typeof a=="undefined")a=window.event;
   if(typeof a.layerX=="undefined")a.layerX=a.offsetX;
   if(typeof a.layerY=="undefined")a.layerY=a.offsetY;
   return a;
  }
}

//-------------------------------------------------------------------
//Resize Object
var Resize={
        "obj":null,
 "init":function(a, aRoot, direct, constrain, minw, minh, maxw, maxh){
   a.onmousedown=Resize.start;
   a.root = aRoot;
   a.direct = direct; // 0-NW 1-SW 2-NE 3-SE
   a.constrain = constrain;
   if (minw) a.minw = minw;
   if (minh) a.minh = minh;
   if (maxw) a.maxw = maxw;
   if (maxh) a.maxh = maxh;
   if(isNaN(parseInt(a.root.style.left)))a.root.style.left="0px";
   if(isNaN(parseInt(a.root.style.top)))a.root.style.top="0px";
   a.root.onResizeStart=new Function();
   a.root.onResizeEnd=new Function();
   a.root.onResize=new Function();
  },
 "start":function(a){
   window.event.cancelBubble = true;
   var b=Resize.obj=this;
   a=Resize.fixE(a);
   var c=parseInt(b.root.style.top);
   var d=parseInt(b.root.style.left);
   b.root.onResizeStart(d,c,a.clientX,a.clientY);
   b.lastMouseX=a.clientX;
   b.lastMouseY=a.clientY;
   document.onmousemove=Resize.resize;
   document.onmouseup=Resize.end;
   return false;
  }, 
 "resize":function(a){
   a=Resize.fixE(a);
   var b=Resize.obj;
   var c=a.clientY;
   var d=a.clientX;
   var e=parseInt(b.root.style.top);
   var f=parseInt(b.root.style.left);
   var wt=parseInt(b.root.style.width);
   var ht=parseInt(b.root.style.height);
   var h,g,hh,ww;
   h=f+d-b.lastMouseX;
   g=e+c-b.lastMouseY;
   switch (b.direct) {
    case 0:
     var cx = (b.lastMouseX-d);
     var cy = (b.lastMouseY-c);
     var hh = (ht+cy);
     if (b.minh && hh < b.minh) {
      hh = b.minh;
     }
     if (b.maxh && hh > b.maxh) {
      hh = b.maxh;
     }
     var ww = Math.floor(hh*b.constrain);
     b.root.style.height = hh+"px";
     b.root.style.width = ww+"px";
     b.root.style.left=h+"px";
     b.root.style.top=g+"px";
     
     break;
    case 1:
     var cx = (b.lastMouseX-d);
     var cy = (b.lastMouseY-c);
     var hh = (ht-cy);
     if (b.minh && hh < b.minh) {
      hh = b.minh;
     }
     if (b.maxh && hh > b.maxh) {
      hh = b.maxh;
     }
     var ww = Math.floor(hh*b.constrain);
     b.root.style.height = hh+"px";
     b.root.style.width = ww+"px";

     b.root.style.left=h+"px";
     break;
    case 2:
     var cx = (b.lastMouseX-d);
     var cy = (b.lastMouseY-c);
     var hh = (ht+cy);
     if (b.minh && hh < b.minh) {
      hh = b.minh;
     }
     if (b.maxh && hh > b.maxh) {
      hh = b.maxh;
     }
     var ww = Math.floor(hh*b.constrain);
     b.root.style.height = hh+"px";
     b.root.style.width = ww+"px";

     b.root.style.top=g+"px";
     break;
    case 3:
     var cx = (b.lastMouseX-d);
     var cy = (b.lastMouseY-c);
     var hh = (ht-cy);
     if (b.minh && hh < b.minh) {
      hh = b.minh;
     }
     if (b.maxh && hh > b.maxh) {
      hh = b.maxh;
     }
     var ww = Math.floor(hh*b.constrain);
     b.root.style.height = hh+"px";
     b.root.style.width = ww+"px";

     break;
   }
   b.lastMouseX=d;
   b.lastMouseY=c;
   b.root.onResize(h,g,a.clientX,a.clientY);
   return false;
  },
 "end":function(){   
   document.onmousemove=null;
   document.onmouseup=null;
   Resize.obj.root.onResizeEnd(parseInt(Resize.obj.root.style.left),parseInt(Resize.obj.root.style.top));
   Resize.obj=null;
  },
 "fixE":function(a){
   if(typeof a=="undefined")a=window.event;
   if(typeof a.layerX=="undefined")a.layerX=a.offsetX;
   if(typeof a.layerY=="undefined")a.layerY=a.offsetY;
   return a;
  }
}

 

用到的图片[相框]:

下载前可以先看下教程 https://pan.quark.cn/s/a426667488ae 标题“仿淘宝jquery图片左右切换带数字”揭示了这是一个关于运用jQuery技术完成的图片轮播机制,其特色在于具备淘宝在线平台普遍存在的图片切换表现,并且在整个切换环节中会展示当前图片的序列号。 此类功能一般应用于电子商务平台的产品呈现环节,使用户可以便捷地查看多张商品的照片。 说明中的“NULL”表示未提供进一步的信息,但我们可以借助标题来揣摩若干核心的技术要点。 在构建此类功能时,开发者通常会借助以下技术手段:1. **jQuery库**:jQuery是一个应用广泛的JavaScript框架,它简化了HTML文档的遍历、事件管理、动画效果以及Ajax通信。 在此项目中,jQuery将负责处理用户的点击动作(实现左右切换),并且制造流畅的过渡效果。 2. **图片轮播扩展工具**:开发者或许会采用现成的jQuery扩展,例如Slick、Bootstrap Carousel或个性化的轮播函数,以达成图片切换的功能。 这些扩展能够辅助迅速构建功能完善的轮播模块。 3. **即时数字呈现**:展示当前图片的序列号,这需要通过JavaScript或jQuery来追踪并调整。 每当图片切换时,相应的数字也会同步更新。 4. **CSS美化**:为了达成淘宝图片切换的视觉效果,可能需要设计特定的CSS样式,涵盖图片的排列方式、过渡效果、点状指示器等。 CSS3的动画和过渡特性(如`transition`和`animation`)在此过程中扮演关键角色。 5. **事件监测**:运用jQuery的`.on()`方法来监测用户的操作,比如点击左右控制按钮或自动按时间间隔切换。 根据用户的交互,触发相应的函数来执行...
垃圾实例分割数据集 一、基础信息 • 数据集名称:垃圾实例分割数据集 • 图片数量: 训练集:7,000张图片 验证集:426张图片 测试集:644张图片 • 训练集:7,000张图片 • 验证集:426张图片 • 测试集:644张图片 • 分类类别: 垃圾(Sampah) • 垃圾(Sampah) • 标注格式:YOLO格式,包含实例分割的多边形点坐标,适用于实例分割任务。 • 数据格式:图片文件 二、适用场景 • 智能垃圾检测系统开发:数据集支持实例分割任务,帮助构建能够自动识别和分割图像中垃圾区域的AI模型,适用于智能清洁机器人、自动垃圾桶等应用。 • 环境监控与管理:集成到监控系统中,用于实时检测公共区域的垃圾堆积,辅助环境清洁和治理决策。 • 计算机视觉研究:支持实例分割算法的研究和优化,特别是在垃圾识别领域,促进AI在环保方面的创新。 • 教育与实践:可用于高校或培训机构的AI课程,作为实例分割技术的实践数据集,帮助学生理解计算机视觉应用。 三、数据集优势 • 精确的实例分割标注:每个垃圾实例都使用详细的多边形点进行标注,确保分割边界准确,提升模型训练效果。 • 数据多样性:包含多种垃圾物品实例,覆盖不同场景,增强模型的泛化能力和鲁棒性。 • 格式兼容性强:YOLO标注格式易于与主流深度学习框架集成,如YOLO系列、PyTorch等,方便研究人员和开发者使用。 • 实际应用价值:直接针对现实世界的垃圾管理需求,为自动化环保解决方案提供可靠数据支持,具有重要的社会意义。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值