简体   繁体   English

我可以在使用 ngx-image-cropper 裁剪图像之前更改图像的亮度和对比度吗?

[英]Can I change the brightness and contrast of an image before cropping it with ngx-image-cropper?

Question - Is there any easy way (ex. CSS) to change the brightness and contrast of an image before sending it to ngx-image-cropper , so that when I call crop() the brightness/contrast persist to the final cropped output image?问题- 在将图像发送到ngx-image-cropper之前,是否有任何简单的方法(例如 CSS)更改图像的亮度和对比度,这样当我调用 crop() 时,亮度/对比度会持续到最终裁剪的 output 图像?

Ex.前任。 load it into a viewer (ex. img tag), adjust brightness, then load it into the cropper window, adjust the zoom, cropped area, etc, then call crop() on the image to get the final output.将其加载到查看器中(例如 img 标签),调整亮度,然后将其加载到裁剪器 window 中,调整缩放比例、裁剪区域等,然后在图像上调用 crop() 以获得最终的 output。

Problem - Nothing I'm trying seems to work to change the brightness of the final cropped image output and I'm aware the ngx-image-cropper library doesn't allow me to adjust brightness or contrast.问题- 我正在尝试的任何事情似乎都无法改变最终裁剪图像的亮度 output 并且我知道 ngx-image-cropper 库不允许我调整亮度或对比度。 I can only zoom and rotate.我只能缩放和旋转。 I'm also aware there are other libraries to do this, I'm stuck on finding one for Angular that is easy free and simple to use.我也知道还有其他库可以执行此操作,我一直在为 Angular 寻找一个免费且易于使用的库。

I have created and set up a Stackblitz demo here to show the process I use to get and crop an image.我在这里创建并设置了一个 Stackblitz 演示,以展示我用来获取和裁剪图像的过程。

Maybe I need to rethink the way I'm working with and editing an image, while using the cropper library?在使用 cropper 库时,也许我需要重新考虑我处理和编辑图像的方式?

Here is the code to demo the process这是演示该过程的代码

 export class AppComponent { @ViewChild(ImageCropperComponent) imageCropper: ImageCropperComponent; name = 'Angular'; imageChangedEvent: any = ''; croppedImage: any = ''; fileChangeEvent(event: any): void { this.imageChangedEvent = event; } imageCropped(event: ImageCroppedEvent) { // this.croppedImage = event.base64; } load() { const croppedImageEvent = this.imageCropper.crop(); this.croppedImage = croppedImageEvent.base64; } imageLoaded() { // show cropper } cropperReady() { // cropper ready } loadImageFailed() { // show message } }
 <input type="file" (change)="fileChangeEvent($event)" /> <image-cropper [imageChangedEvent]="imageChangedEvent" [maintainAspectRatio]="true" [aspectRatio]="3 / 2" [resizeToWidth]="300" format="png" (imageCropped)="imageCropped($event)" (imageLoaded)="imageLoaded()" (cropperReady)="cropperReady()" (loadImageFailed)="loadImageFailed()" ></image-cropper> <div style="padding-bottom: 1rem"> <input type="button" value="Load cropped image" (click)="load()" /> </div> <img [src]="croppedImage" />

ngx-image-cropper only supports cropping related features. ngx-image-cropper只支持裁剪相关的功能。 It doesn't come with other features such as brightness or contrast adjustment.它没有其他功能,例如亮度或对比度调整。

One of the popular paid library is pintura which supports Angular out of the box.流行的付费图书馆之一是pintura ,它开箱即用地支持 Angular。

If you are only interested in open-source library, then this site has a good list: https://medevel.com/16-os-photo-image-editors/如果您只对开源库感兴趣,那么这个网站有一个很好的列表: https://medevel.com/16-os-photo-image-editors/

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

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