Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Add encoderOptions to toDataURL() #66

Open
abrichr opened this issue Oct 30, 2020 · 4 comments
Open

Add encoderOptions to toDataURL() #66

abrichr opened this issue Oct 30, 2020 · 4 comments

Comments

@abrichr
Copy link

abrichr commented Oct 30, 2020

The call to canvas.toDataURL() omits the second parameter for controlling the image quality:

return this.getCanvas().toDataURL(this.screenshotFormat);

From https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL

canvas.toDataURL(type, encoderOptions);
...
encoderOptions Optional
A Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp.
If this argument is anything else, the default value for image quality is used. The default value is 0.92. Other arguments are ignored.

It would be useful to be able to specify a value of 1.0 for maximum image quality.

@VinceG
Copy link
Owner

VinceG commented Oct 30, 2020

@abrichr As a prop pass it down or just hard code it to 1.0 ?

return this.getCanvas().toDataURL(this.screenshotFormat, this.quality); 
or
return this.getCanvas().toDataURL(this.screenshotFormat, 1.0); 

@abrichr
Copy link
Author

abrichr commented Oct 30, 2020

As a prop would be ideal:

return this.getCanvas().toDataURL(this.screenshotFormat, this.quality); 

@VinceG
Copy link
Owner

VinceG commented Oct 30, 2020

@abrichr Going to try and add it, if you have the time and would like to submit a PR that'll be great.

@abrichr
Copy link
Author

abrichr commented Oct 30, 2020

@VinceG thank you for the quick reply! I may submit a PR if we end up using vue-web-cam, but I'm considering whether to use <input capture="camera"> instead. I submitted another issue about it here: #67

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants