Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way I can retain a grayscale filter applied to an image? #1127

Closed
JamesDonnelly opened this issue May 15, 2017 · 4 comments
Closed
Labels

Comments

@JamesDonnelly
Copy link

I've been using this for a while now and I think it's awesome, but I've come across a small issue which I'm hoping there's a simple solution for.

Here is an example of some content which is rendered within my application:

Example 1

Notice the grayscale effect applied to the second obtained image.

Here's how it looks when rendered through html2canvas:

Example 2

Notice how the grayscale effect isn't applied any more?

The effect is applied with:

-webkit-filter: grayscale(100%);
filter: grayscale(100%);

Is there any way I can retain this grayscale effect?

@JamesDonnelly
Copy link
Author

I've created a CodePen example of this in action: https://codepen.io/inb4/pen/LyBLeq.

Code

<figure class="grayscale"></figure>
.grayscale {
  -webkit-filter: grayscale(100%);
  filter: grayscale(100%);
}
html2canvas(..., {
  allowTaint: true
});

Output

Image

@eKoopmans
Copy link
Contributor

Hi @JamesDonnelly, html2canvas doesn't currently support the filter CSS. Support for each feature has to be coded individually, and it looks like filter has a lot of pieces and not great browser support, so unless an ambitious coder feels up to the challenge, I don't expect it will be supported in the near future.

@niklasvh
Copy link
Owner

niklasvh commented Sep 7, 2017

Closing in favor of #493

@cyan33
Copy link

cyan33 commented Feb 9, 2018

I wrote a small library which resolves this issue, hope it helps:
https://github.com/cyan33/image-screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants