http://jsfiddle.net/YN7ba/のように画像をトリミングするときにプレビューを作成しようとしています
With region: 'east'
is preview has width:130
and height:100
, and region: 'center'
is original image
しかし、私が画像プレビューをトリミングすると、
これが私のコードです
tbar:[{
text:'Crop',
handler:function(){
var me = this;
$("#myavatar").Jcrop({
aspectRatio: 1,
minSize : [130,100],
onSelect:me.getCoords,
onChange:me.getCoords
},function(){
// Use the API to get the real image size
var bounds = this.getBounds();
boundx = bounds[0];
boundy = bounds[1];
});
},
getCoords:function(c){
if (parseInt(c.w) > 0) {
xsize = 130,
ysize = 100;
var rx = xsize / c.w;
var ry = ysize / c.h;
$pimg = $('#preview');
$pimg.css({
width: Math.round(rx * boundx) + 'px',
height: Math.round(ry * boundy) + 'px',
marginLeft: '-' + Math.round(rx * c.x) + 'px',
marginTop: '-' + Math.round(ry * c.y) + 'px'
});
}
}
}],
そのおかげで修正する方法。