Skip to content
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

Don't use mozGetAsFile when quality is passed #13

Open
dantman opened this issue Feb 22, 2015 · 4 comments
Open

Don't use mozGetAsFile when quality is passed #13

dantman opened this issue Feb 22, 2015 · 4 comments

Comments

@dantman
Copy link

dantman commented Feb 22, 2015

mozGetAsFile doesn't accept a quality argument like toDataURI as a result the quality argument on toBlob won't have an effect on jpeg and webp images.

@eligrey
Copy link
Owner

eligrey commented Feb 22, 2015

The performance benefits greatly outweigh the slight performance increase of using quality+toDataURI as the base64 encoding overhead is still much much greater. Unfortunately no matter what (reasonably high enough) quality is selected in toDataURI, it will always be slower than mozGetAsFile. Do you have any significant non-performance reasons to use quality+toDataURI?

@dantman
Copy link
Author

dantman commented Feb 22, 2015

Performance? Stripping the quality gives you the wrong file. The point of quality is to affect the image quality / filesize of the file. If you strip it out then you're not giving the file that toBlob is expected to give out.

Local performance is irrelevant if you upload the wrong quality blob to the server.

It's pretty irrelevant anyways since Firefox has native toBlob now. The only people using mozGetAsFile are using outdated Firefox. Trying to optimize performance for them at the cost of getting the correct output is pointless.

@eligrey
Copy link
Owner

eligrey commented Feb 22, 2015

The whole point of using toBlob instead of toDataURL is performance, and it's not like I added the moz method to support old Firefoxes--it was added back when it was the only performant method in any Firefox. You are still getting the correct image format, just not at the desired quality.

I understand your concern though and I will accept a patch that uses toDataURL instead of the moz method when the format is image/jpeg and a non-1 quality is specified.

@dantman
Copy link
Author

dantman commented Feb 22, 2015

The whole point of using toBlob instead of toDataURL is performance, and it's not like I added the moz method to support old Firefoxes--it was added back when it was the only performant method in any Firefox. You are still getting the correct image format, just not at the desired quality.

To me the whole point of using toBlob instead of toDataURL is getting a format that XHR2 will accept and upload with xhr.upload.

In any case thanks for responding. I don't need the IE9- base64 support or toBlobHD so I just went with using canvas-to-blob for my project.

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

No branches or pull requests

2 participants