首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JCrop大图像问题

JCrop大图像问题
EN

Stack Overflow用户
提问于 2015-09-29 14:43:12
回答 1查看 124关注 0票数 0

可以设置一些maxWidth和maxHeight来裁剪大图像吗?我在文档中发现了maxSize,但它只适用于选择区域。我也试过trueSize

代码语言:javascript
复制
function initJCrop(){
    // Create variables (in this scope) to hold the API and image size
    var jcrop_api,
        boundx,
        boundy,

        // Grab some information about the preview pane
        $preview = $('#preview-pane'),
        $pcnt = $('#preview-pane .preview-container'),
        $pimg = $('#preview-pane .preview-container img'),

        xsize = $pcnt.width(),
        ysize = $pcnt.height();

    //console.log('init',[xsize,ysize]);
    $('#imageEdit').Jcrop({
      onChange: updatePreview,
      onSelect: updatePreview,
      aspectRatio: 220 / 55,


    },  function(){
      // Use the API to get the real image size
      var bounds = this.getBounds();
      boundx = bounds[0];
      boundy = bounds[1];
      // Store the API in the jcrop_api variable
      jcrop_api = this;

      jcrop_api.animateTo([ 120,120,20,20 ]);
      jcrop_api.trueSize([200, 100])
      // Move the preview into the jcrop container for css positioning
      $preview.appendTo(jcrop_api.ui.holder);

    });

现在我的形象就像这个。它们超出了模态的范围:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-01 07:22:45

我找到答案了。您应该使用boxHeight和boxWidth选项。如下所示:

代码语言:javascript
复制
$('#imageEdit').Jcrop({
      onChange: updatePreview,
      onSelect: updatePreview,
      aspectRatio: 220 / 55,
      boxWidth: 350

    },  function(){
      // Use the API to get the real image size
      var bounds = this.getBounds();
      boundx = bounds[0];
      boundy = bounds[1];
      // Store the API in the jcrop_api variable
      jcrop_api = this;

      jcrop_api.animateTo([ 120,120,20,20 ]);
    //  jcrop_api.trueSize([200, 100])
      // Move the preview into the jcrop container for css positioning
      $preview.appendTo(jcrop_api.ui.holder);

    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32846973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档