简体   繁体   中英

Ui cropper crop height and width

I am using angualarjs. I want to crop image so i used ui-cropper library.

Followed:

https://codepen.io/Crackeraki/pen/zvWqJM

here is my code:

<div>Select an image file: <input type="file" id="fileInput" /></div>
    <div class="cropArea">
      <ui-cropper image="myImage" area-type="rectangle" aspect-ratio="1.7" result-image="myCroppedImage" result-image-size='{w: 340,h: 200}' init-max-area="true"></ui-cropper>
    </div>

    <div>Cropped Image:</div>
    <div><img ng-src="{{myCroppedImage}}" /></div>

I want show default cropping area of width(crop-width) to be 100% and height(crop-height) to be 100px.

here i am using some aspect ratio 1.7. But i want the crop area width to be 100% for any image.

I need like this:

在此处输入图片说明

But, its coming like below :(

在此处输入图片说明

Please suggest me how can i achieve that.

Select an image file:
 <div class="cropArea"> <ui-cropper image="myImage" area-type="rectangle" aspect-ratio="0" result-image="myCroppedImage" result-image-size='{w: 340,h: 200}' init-max-area="true"></ui-cropper> </div> <div>Cropped Image:</div> <div><img ng-src="{{myCroppedImage}}" /></div> 

You need to change aspect-ratio="1.7" to aspect-ratio="0" then it will take default selected region to that particular image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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