[英]how to combine ngx-compress-image and ngx-image-cropper
I want to upload an image, by letting user to select using input[type=file]
compress it, have a preview and then let user crop the image and post it to API endpoint我想上传图像,让用户使用
input[type=file]
压缩到 select 压缩它,进行预览,然后让用户裁剪图像并将其发布到 API 端点
<input type='file' onchange='compress($event)>
do far I am able to select the image and compress it via ngx-compress-image
the compress image is being shown in the preview. <input type='file' onchange='compress($event)>
到目前为止,我能够 select 图像并通过ngx-compress-image
压缩它,压缩图像显示在预览中。 but now i want to pass this compressed image to ngx-image-cropper
which expects a FileEvent
event.但现在我想将此压缩图像传递给需要
FileEvent
事件的ngx-image-cropper
cropper。 how do i problematically pass the compressed image我如何有问题地传递压缩图像
<input type="file" (change)="fileChangeEvent($event)" />
<image-cropper
[imageChangedEvent]="imageChangedEvent"
[maintainAspectRatio]="true"
[aspectRatio]="4 / 3"
format="png"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded()"
(cropperReady)="cropperReady()"
(loadImageFailed)="loadImageFailed()"
></image-cropper>
<img [src]="croppedImage" />
In case someone else would look a solution to combine these plugins.以防其他人会寻找组合这些插件的解决方案。 The cropper plugging has other
@Inputs()
exposed as well.裁剪器堵塞还暴露了其他
@Inputs()
。 so i used the base64 like below.所以我使用了 base64,如下所示。
<image-cropper
[imageBase64]="ImageToCrop" // <----- added this
[maintainAspectRatio]="true"
[aspectRatio]="4 / 3"
format="png"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded()"
(cropperReady)="cropperReady()"
(loadImageFailed)="loadImageFailed()"
></image-cropper>
<img [src]="croppedImage" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.