简体   繁体   English

使用angualr4如何使用ngx-image-cropper和裁纸器x1,y1和x2,y2位置获取图像文件的实际宽度和大小

[英]Using angualr4 how to get image file actual width and size with ngx-image-cropper and cropper x1,y1 and x2,y2 positions

我正在尝试使用带有angular4的ngx-image-cropper获取原始图像的大小,宽度和高度,以及如何获取裁剪图像的左上角,左下角,右上角,右下角坐标。

im not sure if its this what you want but i got the current widht,height, x1, y1 setting the [cropper] input attribute 即时通讯不确定它是否是您想要的,但是我得到了当前的宽度,高度,x1,y1,设置了[cropper]输入属性

<image-cropper
      [imageChangedEvent]="imageChangedEvent"
      [maintainAspectRatio]="true"
      [aspectRatio]="2 / 1"
      [resizeToWidth]="192"
      [cropper] =" coordinates" //this get the current coordinates
      format="png"
      (imageCropped)="imageCropped($event)"
      (imageLoaded)="imageLoaded($event)"
      (loadImageFailed)="loadImageFailed()"
  ></image-cropper>

and in the .ts file you create a coordinate object, in this case the object name is coordinates 并在.ts文件中创建一个坐标对象,在这种情况下,对象名称为坐标

export class ImageHolderComponent implements OnInit {

  coordinates = {x:0} // object that saves the crop coordinates
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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