I try to make preview when i crop a image look like http://jsfiddle.net/YN7ba/
With region: 'east'
is preview has width:130
and height:100
, And region: 'center'
is origal image
But when i crop the image preview not correct like
Here is my code
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'
});
}
}
}],
How to fix that thanks.