Browse Source

Return the no pixel string async if a callback was passed in

master
Luke Childs 8 years ago
parent
commit
f6d8214017
  1. 10
      lib/canvas.js

10
lib/canvas.js

@ -231,11 +231,6 @@ Canvas.prototype.toDataURL = function(a1, a2, a3){
// ['image/jpeg', qual, fn] -> ['image/jpeg', {quality: qual}, fn]
// ['image/jpeg', undefined, fn] -> ['image/jpeg', null, fn]
if (this.width === 0 || this.height === 0) {
// Per spec, if the bitmap has no pixels, return this string:
return "data:,";
}
var type = 'image/png';
var opts = {};
var fn;
@ -264,6 +259,11 @@ Canvas.prototype.toDataURL = function(a1, a2, a3){
}
}
if (this.width === 0 || this.height === 0) {
// Per spec, if the bitmap has no pixels, return this string:
return fn ? fn(null, "data:,") : "data:,";
}
if ('image/png' === type) {
if (fn) {
this.toBuffer(function(err, buf){

Loading…
Cancel
Save