我浏览了https://github.com/fengyuanchen/cropperjs提供的文档,但在那里找不到任何信息。我还尝试使用像 imgAreaSelect 这样的库,它提供 x1、y1、x2、y2 格式的坐标信息。
var image = document.getElementById('originaImage');
var cropper = new Cropper(image, {
aspectRatio: 16 / 9,
viewMode: 3,
zoomable: false,
minCropBoxWidth: 300,
minCropBoxHeight: 300,
preview: '.previewimg',
movable: false,
zoomable: false,
rotatable: false,
scalable: true,
cropend: function (e) {
/* body... */
},
crop: function(e) {
console.log(e.detail.x);
console.log(e.detail.y);
console.log(e.detail.width);
console.log(e.detail.height);
console.log(e.detail.rotate);
console.log(e.detail.scaleX);
console.log(e.detail.scaleY);
}
});
$('#originaImage').cropper('getData', true) // only has x and y coordinates.