Permalink
Browse files

Prefer toDataURL over mozGetAsFile if the quality parameter is supplied.

Thanks again to rubenstolk for the contribution:
#5
  • Loading branch information...
1 parent bef4f47 commit 578a2030f146f46cbc9e31eeb770801ec67a3d9b @blueimp committed Nov 12, 2012
Showing with 9 additions and 5 deletions.
  1. +7 −3 canvas-to-blob.js
  2. +1 −1 canvas-to-blob.min.js
  3. +1 −1 package.json
View
@@ -1,5 +1,5 @@
/*
- * JavaScript Canvas to Blob 2.0.4
+ * JavaScript Canvas to Blob 2.0.5
* https://github.com/blueimp/JavaScript-Canvas-to-Blob
*
* Copyright 2012, Sebastian Tschan
@@ -72,8 +72,12 @@
};
if (window.HTMLCanvasElement && !CanvasPrototype.toBlob) {
if (CanvasPrototype.mozGetAsFile) {
- CanvasPrototype.toBlob = function (callback, type) {
- callback(this.mozGetAsFile('blob', type));
+ CanvasPrototype.toBlob = function (callback, type, quality) {
+ if (quality && CanvasPrototype.toDataURL && dataURLtoBlob) {
+ callback(dataURLtoBlob(this.toDataURL(type, quality)));
+ } else {
+ callback(this.mozGetAsFile('blob', type));
+ }
};
} else if (CanvasPrototype.toDataURL && dataURLtoBlob) {
CanvasPrototype.toBlob = function (callback, type, quality) {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "blueimp-canvas-to-blob",
- "version": "2.0.4",
+ "version": "2.0.5",
"title": "JavaScript Canvas to Blob",
"description": "JavaScript Canvas to Blob is a function to convert canvas elements into Blob objects.",
"keywords": [

0 comments on commit 578a203

Please sign in to comment.