在JCrop上设置最小高度和宽度

Setting a minimum height and width on JCrop

本文关键字:高度 小高 JCrop 设置      更新时间:2023-09-26

我正在开发一组电子邮件模板,用户可以添加文本、图像、更改字体和颜色等。现在,如果用户想在模板的特定区域添加图像,他们将首先单击要添加图像的区域,然后在我的应用程序中添加库中的图像。现在让我们考虑一下,他们在模板上点击的区域的可接受尺寸是500*500,从库中选择的图像是1000*1000,在这种情况下,应用程序将自动显示一个裁剪工具,他们可以使用该工具调整图像的大小。然而,我想限制裁剪工具只能拖动到模板中所需位置的最小高度或宽度,即,在本例中,他们不应将裁剪工具拖动到500的高度或宽度以下,尽管它们可以保持一个或两个尺寸在500以上,因为裁剪工具自动将其调整大小回到500*500(例如800*500,或者甚至500*1000也是可接受的,因为裁剪刀具自动调整图像大小以适应模板)。我看了一下文件和这个问题,但没有找到合适的答案。以下是我的一些代码,用于验证图像是否需要裁剪:

var SelectedAreaHeight; //returns the height of the area they clicked on the template
var SelectedAreaWidth; //returns the width similarly
function ImageClick(data)
{
var ReturnImageHeight; //returns the height of the area they clicked on
var ReturnImageWidth; //returns the width similarly
    $(".ResizeImage").each(function()
    {
        ReturnImageHeight = $(this).data("height");
        ReturnImageWidth = $(this).data("width");
    }
    });
    if (ReturnImageHeight > SelectedAreaHeight || ReturnImageWidth > SelectedAreaWidth)
    {
        //this checks if the selected image's height OR width is greater
        //than the  desired area in the template to bring up the cropping tool.
    }
}

现在有没有一种方法可以限制裁剪工具,使其在SelectedAreaHeightSelectedAreaWidth以下不能"裁剪"?另外,请忽略上面示例代码的任何问题,因为我还没有粘贴所有的代码(它做的远不止这些)。

Ekhm:Djcrop中有这样一个选项:)

http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options

minSize:array[w,h]:最小宽度/高度,使用0表示无界尺寸n/a