如何在角度4中按矩形裁剪

时间:2018-07-20 04:19:31

标签: angular ng-img-crop

我正在使用ng2-img-cropper进行图像裁剪,但是如果图像为矩形,则无法捕获整个图像,因此无法按矩形尺寸进行裁剪。

1 个答案:

答案 0 :(得分:1)

请尝试以下代码:-

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