2017-08-06 8 views
0

私はhttps://github.com/fengyuanchen/cropperjsで入手可能なドキュメントを調べましたが、そこに情報が見つかりませんでした。私はx1、y1、x2、y2形式の座標情報を提供するimgAreaSelectのようなライブラリを使ってみました。あなたは、あなたがgetData([rounded])fengyuanchen Cropper:切り取った画像のx1、y1、x2、y2座標を取得する方法

を使用することができ、明示的にMath.round()を使用して四捨五入したくない場合は

X2= (Math.round(data.x) + Math.round(data.width)); 
Y2= (Math.round(data.y) + Math.round(data.height)); 

を:私たちが実行してCropperJsで同じことを達成することができimgAreaSelectとJCrop同様

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. 

答えて

関連する問題