cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Enforce rectangle cropper to maintain aspect ratio 3:1 #247

Open cbhatt opened 6 years ago

cbhatt commented 6 years ago

I need to enforce user to crop image in rectangle to maintain aspect ratio 3:1. User can change size of rectangle to select image area. I tried keepAspect but it enforce 1:1 aspect area. Is there any way to enforce rectangle cropper in this library ?

diannall commented 6 years ago

This is what I did:

//canvas this.cropperSettings.canvasWidth = 400; this.cropperSettings.canvasHeight = 300;

//crop size this.cropperSettings.croppedWidth = 300; this.cropperSettings.croppedHeight = 100;

//aspect ratio this.cropperSettings.width = 300; this.cropperSettings.height = 100;

// keep the original image size (minus cropping) this.cropperSettings.preserveSize = true;

this.cropperSettings.keepAspect = true;