jQuery의 새로운 기능입니다. 145x190, 140X180 등과 같은 픽셀에 따라 이미지를 선택하고 싶습니다. 비율로 할 수는 있지만 픽셀이나 치수에 맞지는 않습니다. pls 날 도와. 내 코드는 다음과 같습니다 당신이 try my fiddle 사용자 정의 미리보기 이미지를 만들기 위해 이미지에서 선택합니다 Imgareaselect에서 픽셀 단위로 이미지를 선택할 수있는 방법
function preview(img, selection) {
var scaleX = 100/(selection.width || 1);
var scaleY = 100/(selection.height || 1);
$('#ferret + div > img').css({
width: Math.round(scaleX * 400) + 'px',
height: Math.round(scaleY * 300) + 'px',
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px',
});
}
$(document).ready(function() {
$('<div> <img src="http://jotform.org/demo/jquery-image-area-select-plugin/images/sweet-dogs.jpg" style="position: relative;"> </div>')
.css({
float: 'right',
position: 'relative',
overflow: 'hidden',
width: '100px',
height: '100px'
})
.insertAfter($('#ferret'));
$('#ferret').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview ,minWidth: 100,minHeight: 100});
});
이
이전에 imgAreaSelect를 사용 해본 적이 없지만 고정 크기의 상자를 원할 경우 최소 너비와 최대 너비 및 높이를 지정할 수 있습니다 :'$ ('# ladybug_ant'). imgAreaSelect ({maxWidth : 200, maxHeight : 150, minWidth : 200, minHeight : 150, handles : true});'http://odyniec.net/projects/imgareaselect/examples.html 첫 번째 무당 벌레 이미지 – HMR