question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Canvas.toDataURL is not base64 encoded

See original GitHub issue

calling toDataURL and logging the result gives the below:

data:image/png;base64,�PNG

    �Om
�╝\ ╔+.��    IEND�B`�

there is a base64 function here - https://github.com/ReneNyffenegger/cpp-base64 would that be suitable do you think? I can cut a PR if you think that one could work.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sidequestlegendcommented, Jan 7, 2019

I had exactly the same thought, i had a branch but had some problems sending the buffer back. I see you have it in hand though 😃

0reactions
avaercommented, Jan 7, 2019

Actually I see this is done by Skia: https://github.com/webmixedreality/exokit/blob/master/deps/exokit-bindings/canvascontext/src/canvas-context.cc#L1259

So we could probably get this as an ArrayBuffer (therefore implementing toBlob), and use Buffer to convert that to a base64 string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting binary (base64) data from HTML5 Canvas ...
The canvas element provides a toDataURL method which returns a data: URL that includes the base64-encoded image data in a given format.
Read more >
HTMLCanvasElement.toDataURL() - Web APIs | MDN
The HTMLCanvasElement.toDataURL() method returns a data URL containing a representation of the image in the format specified by the type ...
Read more >
How to Get and Set a Base64 Image on Canvas Using ...
In simpler terms, you will get a PNG image but it has been encoded in base64. For the toDataURL() method, the PNG format...
Read more >
Canvas.toDataURL is not base64 encoded · Issue #704 - GitHub
So we could probably get this as an ArrayBuffer (therefore implementing toBlob ), and use Buffer to convert that to a base64 string....
Read more >
Google Groups
I am not pretty sure the method canvas.toDataURL() returns an encoded 64 base string.I create an png image by mspaint.exe (pic ). The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found