Skip to content

Support canvas.toDataURL("image/jpeg") (sync) #1194

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

Merged
merged 1 commit into from
Jul 5, 2018

Conversation

zbjornson
Copy link
Collaborator

@zbjornson zbjornson commented Jul 2, 2018

This adds the missing, standard sync API; we only had async.

Also fixes a bug I introduced in #1152 (JPEG quality needs to go from 0 to 1, not 0 to 100).

Fixes #1146

Also allows some code to be freed up in JSDOM (jsdom/jsdom#2199).

  • Have you updated CHANGELOG.md?

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
@@ -663,38 +663,31 @@ describe('Canvas', function () {
ctx.fillRect(100,0,100,100);

it('toDataURL() works and defaults to PNG', function () {
assert.ok(0 == canvas.toDataURL().indexOf('data:image/png;base64,'));
assert.ok(canvas.toDataURL().startsWith('data:image/png;base64,'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Copy link
Collaborator

@LinusU LinusU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work 🚀

@chearon chearon merged commit 0f74eed into Automattic:master Jul 5, 2018
@asturur
Copy link
Contributor

asturur commented Aug 5, 2018

@zbjornson This is very cool!
Do you think it can be backported on 1.X or is heavily based on 2.x code?

@zbjornson
Copy link
Collaborator Author

It's heavily 2.x, but once the memory leaks are addressed I think 2.x can be released.

@zbjornson zbjornson deleted the zb/1146 branch August 6, 2018 06:51
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

Successfully merging this pull request may close these issues.

Missing sync canvas.toDataURL("image/jpeg") API
4 participants