我有 3 个不同的 div,其中包含图像。每个 div 具有不同的宽度和高度。我对它们都使用了 jQuery imgAreaSelect。裁剪工作正常。我的问题是我想在裁剪窗口打开时开始进行初始裁剪。我希望这个初始裁剪成为给定纵横比的最大可能部分。
我正在使用的代码是:
var aspectratio1 = $('#cutout_'+cutout_id).height() / $('#cutout_'+cutout_id).width();
aspectratio = "1:" + aspectratio1;
var image_width = $('#CutoutImage').width();
var image_height = $('#CutoutImage').height();
var aspect = 1 / aspectratio1 ;
var NewWidth = Math.round(image_height * aspect);
var left = ((image_width - NewWidth) / 2);
var right = Math.round(NewWidth + left);
var x1 = left;
var y1 = 0;
var x2 = right;
var y2 = image_height;
$('#CutoutImage').imgAreaSelect({
aspectRatio: aspectratio,
instance: true,
zIndex: 9999,
x1: x1,
y1: y1,
x2: x2,
y2: y2
});
这似乎无法正常工作。非常感谢任何帮助或见解。
非常感谢你