知识大全 javascript 图片裁剪技巧
Posted 知
篇首语:春衣少年当酒歌,起舞四顾以笑和。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 javascript 图片裁剪技巧相关的知识,希望对你有一定的参考价值。
学php gd库 看到有图片裁剪 正好整一个 嗯 其实挺简单的
php版 代码如下: <!DOCTYPE > < xmlns=" <head> <meta equiv="Content Type" content="text/; charset=utf " /> <title>Resize</title> <style type=text/css> * padding: ; margin: ; ul list style type:none; overflow:hidden; zoom: ; width: px; margin: px auto; li float:left; width: px; #containerwidth: px; height: px; margin: auto; border: px solid # ; position:relative;background:url #container blockheight: px; width: px; border: px solid # ; position:absolute; left: px; top: px; background:#fff;filter:alpha(opacity=);opacity: ; cursor:move; rRightDown rLeftDown rLeftUp rRightUp rRight rLeft rUp rDown position:absolute;background:#f ;width: px;height: px;z index: ;font size: ; rLeftDown rRightUpcursor:ne resize; rRightDown rLeftUpcursor:nw resize; rRight rLeftcursor:e resize; rUp rDowncursor:n resize; rRightDown bottom: px; right: px; rLeftDown bottom: px; left: px; rRightUp top: px; right: px; rLeftUp top: px; left: px; rRight right: px; top: % rLeft left: px; top: % rUp top: px; left: % rDown bottom: px; left: % #imgC border: px solid #CCC; width: ; height: ; margin: auto;background:url </style> </head> <body> <ul> <li> <div id="container"></div> </li> <li> <div id="imgC"></div> </li> </ul> <script type=text/javascript src=<script type=text/javascript"> (function() var dBody = document body dDoc = document documentElement; var clip = function(options) this init call(this options); clip prototype = options : moveCallBack : function() className : "block" init : function(options) $ extend(this this options options||); if(!this container || !this imgC) return; this container = $(this container); var self = this; this block = $( <div > <div action="rightDown" ></div> <div action="leftDown" ></div> <div action="rightUp" ></div> <div action="leftUp" ></div> <div action="right" ></div> <div action="left" ></div> <div action="up" ></div> <div action="down" ></div> </div> ) bind("mousedown r" function(e)self start(e)) appendTo(this container[ ]); this setImg(); setImg : function() var block = this block; this imgC css( height: block height() width : block width() "background position" : " "+block css("left")+" "+block css("top") ); start : function(e) var $elem = $(e target) block = this block self = this move = false container = this container action = $elem attr("action"); //这个 每次都要计算 基本dom结构的改变 浏览器的缩放 都会让里面的值发生改变 this offset = $ extend(height:container height() width:container width() container offset()); this blockOriginal = height:block height() width:block width() left:parseInt(block css("left")) top:parseInt(block css("top")); if(action) this fun = this[action]; else this x = e clientX this offset left this blockOriginal left ; this y = e clientY this offset top this blockOriginal top; move = true; $(document) bind("mousemove r" function(e)self move(e move)) bind("mouseup r" function()self end()); end : function() $(document) unbind("mousemove r") unbind("mouseup r"); move : function(e isMove) window getSelection ? window getSelection() removeAllRanges() : document selection empty();
var block = this block; if(isMove) var left = Math max( e clientX this offset left this x); left = Math min(left this offset width this blockOriginal width); var top = Math max( e clientY this offset top this y); top = Math min(top this offset height this blockOriginal height); block css(left:left top:top); else var offset = this fun(e); block css(offset); this setImg(); this moveCallBack(); down : function(e) var blockOriginal = this blockOriginal sTop = Math max(dBody scrollTop dDoc scrollTop) //出现垂直方向滚动条时候 要计算这个 offset = this offset;
if(e clientY offset top>=blockOriginal top sTop) var height = Math min(offset height blockOriginal top e clientY offset top blockOriginal top+sTop) top = blockOriginal top; else var height = Math min(offset top+blockOriginal top e clientY sTop blockOriginal top) top = Math max(e clientY offset top+sTop ); return height:height top:top; up : function(e) var blockOriginal = this blockOriginal sTop = Math max(dBody scrollTop dDoc scrollTop) offset = this offset; if(e clientY offset top blockOriginal height<=blockOriginal top sTop) var top = Math max(e clientY offset top+sTop ) maxHeight = blockOriginal top + blockOriginal height height = Math min(maxHeight blockOriginal top + blockOriginal height (e clientY offset top) sTop); else
var height = Math min(e clientY offset top blockOriginal top blockOriginal height+sTop offset height blockOriginal top blockOriginal height) top = blockOriginal top+blockOriginal height; return height:height top:top; left : function(e) var blockOriginal = this blockOriginal offset = this offset;
cha138/Article/program/Java/JSP/201311/19851相关参考
怎么用ps把做好的海报图片改成1920*700“图像-图像大小”中可以设置;或者用裁剪工具(V),设置好尺寸再裁剪而成。ps怎么把做好的图片保存成图片形式?快捷键ctrl+shift+s或者ctrl+
用JavaScript限制图片上传长宽 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! <&
JavaScript制作会反弹的浮动图片 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!现在网上流行
用Javascript使网页图片产生旋转效果 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! Ro
JavaScript创建随机数和随机图片 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!创建随机数①
知识大全 Javascript图片播放类ImageSlide.iclass.js
Javascript图片播放类ImageSlide.iclass.js 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶
知识大全 javascript实现文字图片上下滚动的具体实例
这篇文章介绍了在JS中文字图片上下滚动的实现代码需要的朋友可以参考一下 复制代码代码如下:cha138/Article/program/Java/JSP/201311/20264
javascript遍历网页内的所有图片根据图片的宽高按一定的比率缩小javascript 缩小网页内所有图片大小的方法函数如下: */<scriptlanguage="java
关闭窗口在图片的连接上写javascript:windowclose(); 提交的图片连接写javascript:documentFormsubmit(); 删除之前出现确认对话框<ad
用以下代码<scriptlanguage=JavaScript><!coff=newImage();coffsrc=图片位置;con=newImage();consrc=图片位置;f