简体   繁体   English

如何裁剪具有不同高度/宽度尺寸的区域? 与ngImgCrop

[英]how to crop-area with different height/width size? with ngImgCrop

I'm trying to crop not same height/width crop-area can I use rectangle crop-area. 我尝试裁切不同的高度/宽度裁切区域,可以使用矩形裁切区域。

<div>Select an image file: <input type="file" id="fileInput" /></div>
    <div class="cropArea">
    <img-crop image="myImage" result-image="myCroppedImage" area-type="square" area-min-size="20" result-image-size="150"></img-crop>
     </div>
<div>Cropped Image:</div>
<div><img ng-src="{{myCroppedImage}}" /></div>

I need set height/width like area-min-size="{100, 150}" result-image-size="{100, 150}" 我需要设置高度/宽度,例如area-min-size =“ {100,150}” result-image-size =“ {100,150}”

As far as I can see - it is not possible, as it involves a more complex manipulation of the selector area (eg, it will need to resize in two dimensions independently). 据我所知-这是不可能的,因为它涉及选择器区域的更复杂的操作(例如,它将需要独立地在二维上调整大小)。

There is an alternative however. 但是,还有另一种选择。 Though it might be not as much of an eye candy as ngImgCrop, but it achieves what you need. 尽管它可能不如ngImgCrop那样令人眼花candy乱,但是它可以满足您的需求。 [ http://grab.by/Cbpq ] [ http://grab.by/Cbpq ]

It is called: angular-image-crop . 它被称为: angular-image-crop

Here is a JSBin sample . 这是一个JSBin示例

You may need to play around with the following parameters data-width="", data-height="", dat-shape="square" before the result is satisfying: 在使结果令人满意之前,您可能需要使用以下参数data-width="", data-height="", dat-shape="square"

<image-crop
     data-width="500"
     data-height="300"
     data-shape="square"
     data-step="imageCropStep"
     data-result="imageCropResult"
     ng-show="showImageCropper"
   ></image-crop>

@Bilegsaikhan, I found a modified version of ngImgCrop which supports rectangular crop as well as a fixed aspect ratio. @Bilegsaikhan,我发现了ngImgCrop的修改版,它支持矩形裁剪以及固定的长宽比。 Here I created a JsFiddle . 在这里,我创建了一个JsFiddle

One could fiddle with the result-image-size="400" parameter to tailor the intermediate/resulting image size (this parameter defines the canvas size of an intermediate step). 可以使用result-image-size="400"参数来调整中间/结果图像的大小(此参数定义了中间步骤的画布大小)。 For the size of the final img , normal height and width of the image node can be changed. 对于最终img的大小,可以更改图像节点的正常heightwidth

Enjoy :) 请享用 :)

have you tried this library https://github.com/vogloblinsky/ngImgCropExtended ? 您是否尝试过该库https://github.com/vogloblinsky/ngImgCropExtended It probably extends the feature from ngImgCrop and supports area type like circle, square and rectangle 它可能扩展了ngImgCrop的功能并支持圆形,正方形和矩形等区域类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM