http://love21cn.msn.com.cn的图片上传功能后可以实现区域截图,也可以实现放大缩小...估计是用了JS来实现的:
var div_move = 0;
var IE = document.all?true:false;
var tempX,tempY,oldX,oldY;
var have_move = 0;
function grasp()
{
div_move = 1;
if(IE)
{
document.getElementById("source_div").setCapture();
}
}
function free()
{
div_move = 0;
have_move = 0;
document.getElementById("source_div").releaseCapture();
}
function getMouseXY(e)
{
if (IE)
{ // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
}
else
{
// grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
}
function move_it(e)
{
getMouseXY(e);
if(div_move == 1)
{
if(have_move == 0)
{
//alert('a');
oldX = tempX;
oldY = tempY;
have_move = 1;
}
var left = parseInt(document.getElementById("source_div").style.left);
var top = parseInt(document.getElementById("source_div").style.top);
//alert(top);
//alert(left);
//alert(tempX);
//alert(oldX);
document.getElementById("source_div").style.left = left + tempX - oldX;
document.getElementById("source_div").style.top = top + tempY - oldY;
oldX = tempX;
oldY = tempY;
}
}
function change_size(method)
{
if(method == 1)
{
var per = 1.25;
}
else
{
var per = 0.8;
}
document.getElementById("show_img").width = document.getElementById("show_img").width*per;
//document.getElementById("show_img").height = document.getElementById("show_img").height*per;
}
function micro_move(method)
{
switch (method)
{
case "up":
var top = parseInt(document.getElementById("source_div").style.top);
document.getElementById("source_div").style.top = top - 5;
break;
case "down":
var top = parseInt(document.getElementById("source_div").style.top);
document.getElementById("source_div").style.top = top + 5;
break;
case "left":
var left = parseInt(document.getElementById("source_div").style.left);
document.getElementById("source_div").style.left = left - 5;
break;
case "right":
var left = parseInt(document.getElementById("source_div").style.left);
document.getElementById("source_div").style.left = left + 5;
break;
}
}
function turn(method)
{
var i=document.getElementById('show_img').style.filter.match(/\d/)[0]
//alert(i);
i=parseInt(i)+parseInt(method);
//alert(i);
if(i<0)
{
i += 4;
}
if(i>=4)
{
i -= 4;
}
//alert(i);
document.getElementById('show_img').style.filter='progid:DXImageTransform.Microsoft.BasicImage(Rotation='+i+')'
}
function mysub()
{
var Oform = document.myform;
Oform.go.value = 1;
Oform.width.value = document.getElementById("show_img").width;
Oform.left.value = document.getElementById("source_div").style.left;
Oform.top.value = document.getElementById("source_div").style.top;
if(IE)
{
Oform.turn.value = document.getElementById('show_img').style.filter.match(/\d/)[0];
}
Oform.submit();
}
苹果树下也有类似功能不过,功能要比你所说的强大的多...
资料搜集于网络知道!
『贰』 JS怎么把图片分成一个个小块
两个方法,没现成代码,自己想办法搞:
简单的:js判断鼠标在图片上时,产生一个div覆盖在图片上面,这个div给格子背景图
(兼容性好,但是格子尺寸固定,一张网页上多个不同尺寸图片上用,格子全一样大)
复杂的:js生成个html5的canvas画布,把图片放上去,再用js画些线条在上面
(无法顾及不支持html5的浏览器,但是格子尺寸你可以根据图片尺寸比例动态生成)
『叁』 js图片编辑器
手机体验地址: http://114.67.68.76:8080/roc/imgDist/
github地址: https://github.com/lijibing01/picture_edit
1、引入dist文件夹下的ped.js
2、渣塌new window.PED.imageInfo(url,saveFn)
1、卜梁判可以双指放大缩小图片
2、可以在图片上进行涂鸦
2、可以输入文字,输入文字后可以单指移动文字在图片上的位置
3、可以撤回涂鸦的内容,不能撤回文型改字,文字编辑功能还未实现
1、npm install
2、npm run build
欢迎star
『肆』 怎样用JS截取剪裁图片,并得到剪裁后的图片(不是那种视觉上的裁剪),求代码~~~~~~
一般都是页面加载一个大图 从大图上截取的 控制像素
『伍』 Html5移动端上传图片并裁剪 - Clipic.js
Clipic.js插件可以为移动端 (仅支持移动端) 提供头像上传并裁剪成指定尺寸,用原生js开发的,轻量级,包含html跟css,不到8kb。点此链接体验: https://teojs.github.io/clipic/
https://github.com/teojs/clipic
参数说明
width:Number (默认:500) – 裁剪宽度
height:Number (默认:500) – 裁剪高度
ratio:Number (可选) – 裁剪的比例,当传入ratio时width/height将无效
src:String (必传) – 需要裁喊禅剪的图片,可以是图片链接,或者 base64
type:String (默认:jpeg) – 裁剪后图片的类型,仅支持 jpeg/png 两种
quality:Number (默认:0.9) – 压缩质量
buttonText:Array (默认:[‘取消’, ‘重置’, ‘完成’]) – 底部三郑正尘个按钮文本清型
http://bbs.itying.com/topic/5cb17892c6a71b10bcef96b0
『陆』 用js实现图片复制到剪切板的功能,兼容各种浏览器,例如IE,火狐、chome等。
您好!很高兴为您答疑!
只能复制图片地址,想直接复制图片,目前还做不到。
您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
『柒』 js 手机屏上两根手指放大缩小图片(类似app图片放大缩小效果)
网络有个touch.js,支持各种手势,包括缩放pinch事件,pinchin是缩小,pinchout是放大。