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

toBlob won't save to a jpeg #458

Open
funkyvisions opened this issue Mar 26, 2024 · 2 comments
Open

toBlob won't save to a jpeg #458

funkyvisions opened this issue Mar 26, 2024 · 2 comments
Labels

Comments

@funkyvisions
Copy link

Expected Behavior

toBlob(node, { type: "image/jpeg" }) should get a blob with a jpeg embedded

Current Behavior

toBlob(node, { type: "image/jpeg" }) is always embedding a png

Possible Solution

toBlob is calling canvasToBlob WITHOUT the options

Steps To Reproduce

const blob = await htmlToImage.toBlob(elem, { type: "image/jpeg" })

Blob has type "image/png"

Additional Context

Your Environment

  • html-to-image: 1.11.11
  • OS: macOS Sonoma 14.4
  • Browser: Chrome
@biiibooo
Copy link
Contributor

biiibooo bot commented Mar 26, 2024

👋 @funkyvisions

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@Mika1412x
Copy link

Mika1412x commented Jul 20, 2024

You can fix this bug by editing the code at line 54 in the file /node_modules/html-to-image/es/index.js as follows:
const blob = await canvasToBlob(canvas); -> const blob = await canvasToBlob(canvas, options);
I recommend using patch-package at https://www.npmjs.com/package/patch-package

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

2 participants