-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Missing sync canvas.toDataURL("image/jpeg") API #1146
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
Comments
You're right, Until that's fixed, you could use |
@zbjornson , yes, but again the canvas on which I'm using toDataURL() is an htmlcanvas element, which goes through jsdom and then goes to node canvas, and jsdom does not have jpegStream() so is there a way i can create a node-canvas object using a html canvas element. If so, that would solve the issue |
Sorry -- I meant you could do that by accessing the node-canvas Canvas instance that jsdom wraps, which I think is just They actually provide their own implementation of |
@zbjornson the _getCanvas does not exist in my HTMLCanvasElement, this method belongs to the HTMLCanvasElementImpl class as in HTMLCanvasElementImpl.js. I am unable to find the HTMLCanvasElementImpl instance in my HTMLCanvasElement |
My bad. Looks like you'd have to use the method described here to get to the canvas instance: jsdom/jsdom#2067. |
The toBlob method worked. The code below did the job for me
Thanks for helping me out!! PS: I submitted an issue in jsdom jsdom/jsdom#2200 |
Glad that worked. That does look wrong :) -- you could open an issue with jsdom for that. |
Also fixes a bug I introduced in Automattic#1152 (JPEG quality needs to go from 0 to 1, not 0 to 100). Fixes Automattic#1146
Also fixes a bug I introduced in Automattic#1152 (JPEG quality needs to go from 0 to 1, not 0 to 100). Fixes Automattic#1146
I am using jsdom and node-canvas to run frontend html canvas code within node js, one of my script files has the line
canvas.toDataURL('image/jpeg',{quality:1},function(){})
the third parameter is because node-canvas demands 3 parameters over here at line 301 in canvas.js
but jsdom passes only two arguments to this, and it might not be their fault since the official frontend canvas.toDataURL is supposed to take only 2 arguments.
I need to generate pdfs using jpg images generated by canvas in node. Would appreciate any help
The text was updated successfully, but these errors were encountered: