advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
931 stars 130 forks source link

Image filters #185

Closed Domepo closed 2 years ago

Domepo commented 2 years ago

Question

Is there any good way to apply filters (contrast, saturation, brightness, etc.) to the cropped image?

Problem

There is a way to manipulate an image via css, but its not a global change. The preview image for example is not affected

.cropper img{
  filter: brightness(0.1);
}
    <cropper
      class="cropper"
      ref="cropper"
      <!--   it would be cool, to modify the filters directly of the :src"img"-->
      :src="img"
    />
Norserium commented 2 years ago

@Domepo, hello!

There is no a perfect way to do it right now.

You can apply filter to image and preview simultaneously. The example. The limitations are obvious: the number of filters will be limited and you need to apply them to the cropped image separately.

You can change the image itself. It's the most flexible way, but there is the catch. When you change src property the cropper state will be reset. This aspect was discussed in this issue and I offered the workaround there.

I suppose that the regular solution will be available in the next major release on the analogy of react-advanced-cropper method:

cropper.setImage(image);
Domepo commented 2 years ago

Tanks a lot!

Norserium commented 2 years ago

@Domepo, you are welcome. I close this issue, but feel free to reopen it if you encounter any troubles.

Norserium commented 2 years ago

@Domepo, just for your information. I assume that in the next major release it will be implemented in this manner. Any feedback is appreciated.