1、下载链接
cropper : https://github.com/fengyuanchen/cropper
jQuery版 :https://github.com/fengyuanchen/jquery-cropper
2、配置
$('.cover').cropper({
aspectRatio: 16/9,//默认比例
preview: '.cover-chop-clip-img-v2-preview',//预览视图
guides: false, //裁剪框的虚线(九宫格)
autoCropArea:1, //0-1之间的数值,定义自动剪裁区域的大小,默认0.8
movable: false, //是否允许移动图片
dragMode: 'none', //拖拽模式 ‘crop’: 可以产生一个新的裁剪框3‘move’: 只可以移动3‘none’: 什么也不处理
movable: true, //是否允许移动剪裁框
resizable: true, //是否允许改变裁剪框的大小
zoomable: false, //是否允许缩放图片大小
mouseWheelZoom: false, //是否允许通过鼠标滚轮来缩放图片
touchDragZoom: true, //是否允许通过触摸移动来缩放图片
rotatable: false, //是否允许旋转图片
minContainerWidth:430,//容器最小宽度
minContainerHeight:240,//容器最小高度
background:false,
center:false,
viewMode:2,
crop: function(e) {
var imageData = $(this).cropper('getData');
console.log(imageData) console.log(e.width)
console.log(e.height)
}
});