如何在 angular 4 中按 rectangular 裁剪

how to crop by rectangular in angular 4

我正在使用 ng2-img-cropper 进行图像裁剪,但是如果图像是矩形的,那么它不会捕获整个图像,我无法按矩形大小进行裁剪。

请试试这个代码:-

   //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;