2011-06-28 12 views
1

图像的另一部分我有一个问题,这个插件jQuery的图像裁剪的问题 - 显示出比选择

http://odyniec.net/projects/imgareaselect/

我觉得图片说明这一切。

enter image description here 我已经选择了整个图像,但拇指只显示其中的一部分。 即使在更大的图像上,它确实显得很糟糕。我的代码

function preview(img, selection) { 
    if (!selection.width || !selection.height) 
     return; 
    var scaleX = 100/selection.width; 
    var scaleY = 100/selection.height; 

    $('#preview img').css({       
     width: Math.round(scaleX * 300),    
     height: Math.round(scaleY * 300), 
     marginLeft: -Math.round(scaleX * selection.x1), 
     marginTop: -Math.round(scaleY * selection.y1) 
    });            

} 

$(function() { 
    $('#photo').imgAreaSelect({ aspectRatio: '1:1', handles: true, 
     fadeSpeed: 200, onSelectChange: preview }); 
}); 

我试图jcrop但它同样

+0

我需要看到标记为“#preview img”来诊断问题 –

回答

3

看起来你的缩放是关闭您的预览。您的编辑区域和预览显示的大小相同(〜100px),但您的JavaScript设置为300px的编辑区域和100px的预览区域;这意味着您的预览会比应该放大3倍,并且您最终会看到剪辑过大的预览。

+0

。非常感谢 – genesis

0

值“100”是宽度和高度的预览图像,值“300”是宽度和高度的主要图像。