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

Too big image file in Firefox #482

Open
1 of 2 tasks
NogaMan opened this issue Oct 11, 2024 · 1 comment
Open
1 of 2 tasks

Too big image file in Firefox #482

NogaMan opened this issue Oct 11, 2024 · 1 comment

Comments

@NogaMan
Copy link

NogaMan commented Oct 11, 2024

Use case:

I have a page with lots of css variables (around 1333) set in :root, and each of them gets copied into each element inside the canvas, because apparently in Firefox, getComputedStyle returns not only all styles, but all of the applied css variables as well.

Is it possible to add an option something like filterStyles that we could use to filter out which computed styles we want to be included in the saved image and which not? We could use filtering by -- prefix to filter out CSS variables.

Expected behavior

await domtoimage.toJpeg(element,{
  filterStyles(node, propertyName) {
    return !propertyName.startssWith('__');
  }
)

Actual behavior (stack traces, console logs etc)

Currently all 1300 css variables are set on each node, making the image file so big that it fails to be saved in Firefox

Library version

2.6.0

Browsers

  • Chrome 49+
  • Firefox 45+
@NogaMan NogaMan changed the title Too big image field in Firefox Too big image file in Firefox Oct 11, 2024
@forever0714yuan
Copy link

forever0714yuan commented Oct 31, 2024 via email

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

No branches or pull requests

3 participants
@NogaMan @forever0714yuan and others