简体   繁体   English

如何结合 ngx-compress-image 和 ngx-image-cropper

[英]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.

相关问题 ngx-image-cropper IE-11 不工作 angular 7.2 - ngx-image-cropper IE-11 not working angular 7.2 如何在不调用 imageChangedEvent 事件的情况下在 ngx-image-cropper 上加载图像? - How to load the image on the ngx-image-cropper without calling the imageChangedEvent event? 将 ngx-image-cropper 与 ngx-bootstrap-modal 一起使用时 loadImageFailed() 触发错误 - loadImageFailed() trigger error when using ngx-image-cropper with ngx-bootstrap-modal ngx-image-cropper imageloaded() 未将任何图像数据传递给 typescript 文件事件方法 - ngx-image-cropper imageloaded() not passing any image data to typescript file event method 图片上传不正确,Angular 8 和 ngx-image-compress - The image not upload correctly, Angular 8 and ngx-image-compress ngx-gallery 图像未显示 - ngx-gallery image is not displayed ngx-画廊不显示图像 - ngx-gallery not displaying image 使用 ngx-print 打印图像的问题 - Problem with image printing using ngx-print 如何在 Angular 9 中使用 ngx-image-zoom 在 hover 上的图像旁边显示图像缩放弹出窗口? - How to display image zoom popup beside image on hover using ngx-image-zoom in Angular 9? 如何为 ngx-dropzone 中的非图像文件使用自定义缩略图? 角10+ - How do I use a custom thumbnail for non-image files in ngx-dropzone? Angular10+
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM