Search code examples
angularng-img-crop

how to crop by rectangular in angular 4


I am using ng2-img-cropper for image crop but if the image is in rectangular shape then it does not capture the whole image, I am not able to crop by rectangular size.


Solution

  • Please try this code :-

       //canvas
        this.cropperSettings.canvasWidth = 400;
        this.cropperSettings.canvasHeight = 300;
    
        //crop size
        this.cropperSettings.croppedWidth = 300;
        this.cropperSettings.croppedHeight = 150;
    
        //aspect ratio
        this.cropperSettings.width = 150;
        this.cropperSettings.height = 150;
    
        // keep the original image size (minus cropping)
        this.cropperSettings.preserveSize = true;
    
        this.cropperSettings.keepAspect = false;