Canvas#toDataURL() returns image data url string with quotes included
See original GitHub issueCanvas#toDataURL() returns a string like "\"data:image/png;base64,iVB...\""
.
It seems caused by the payload being JSON.stringify()
at web view side: https://github.com/iddan/react-native-canvas/blob/master/src/webview.js#L88
and get returned directly at React Native side:
https://github.com/iddan/react-native-canvas/blob/master/src/Canvas.js#L76
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:8 (1 by maintainers)
Top Results From Across the Web
HTMLCanvasElement.toDataURL() - Web APIs | MDN
toDataURL() method returns a data URL containing a representation of the image in the format specified by the type parameter.
Read more >Blank image when executing canvas.toDataUrl()
So after much trawling through StackOverflow I found the function drawScene() which (somehow?) force toDataURL() to return the image data as ...
Read more >Convert Image to Data URI with JavaScript - Tutorialspoint
In here it is explained how to make a canvas element, load an image into it, and use toDataURL() to display the string...
Read more >node-canvas - npm
Image #src. img.src: string|Buffer. As in browsers, img.src can be set to a data: URI or a remote URL. In addition, node-canvas allows ......
Read more >The HTML5 Canvas Handbook - Bucephalus.org
toDataURL() that translates the full content of the given canvas into code for an image file (PNG or ... Returns a data: URL...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please can we document this as it isn’t the same signature as what is on the web.
Because of me just ignoring the quotes when I read them in the console, I didn’t notice the extra quotes D: Took me a while to figure out that one.
I just ran into this issue after spending a few hours debugging. I worked around it by replacing the quotes in the string returned:
I’m not sure what the best solution is here. Singling out the toDataURL call when choosing whether to stringify the response message in the code @rocwind linked above doesn’t feel right.