toDataURL "error while writing to output stream" when width = 0 and height = 0 #207

Closed
katspaugh opened this Issue Aug 21, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@katspaugh

Hi!

When you create a canvas with the width of 0 and height of 0, you get the following error later when calling toBuffer, toDataURL and other exporting methods:

/usr/local/lib/node_modules/canvas/lib/canvas.js:190
    return prefix + this.toBuffer().toString('base64');
                     ^
Error: error while writing to output stream
    at Canvas.toDataURL (/usr/local/lib/node_modules/canvas/lib/canvas.js:190:26)

How to reproduce:

$ brew install cairo
$ npm install -g canvas    

var Canvas = require('canvas');
var canvas = new Canvas(0, 0); // this is the culprit
canvas.toDataURL();

Versions:

node v0.8.4
node-canvas v0.13.1

@katspaugh katspaugh closed this Aug 22, 2012

@katspaugh katspaugh reopened this Aug 22, 2012

@katspaugh

This comment has been minimized.

Show comment Hide comment
@katspaugh

katspaugh Aug 22, 2012

Installed cairo and co from source (exactly as per the wiki) to the same avail. The same error.

Installed cairo and co from source (exactly as per the wiki) to the same avail. The same error.

@katspaugh

This comment has been minimized.

Show comment Hide comment
@katspaugh

katspaugh Aug 22, 2012

The same error with createPNGStream.

The same error with createPNGStream.

@Guit

This comment has been minimized.

Show comment Hide comment
@Guit

Guit Mar 16, 2013

Hi :)
Did you fix it?

Guit commented Mar 16, 2013

Hi :)
Did you fix it?

@pawlufelice

This comment has been minimized.

Show comment Hide comment
@pawlufelice

pawlufelice Nov 23, 2015

I get roughly the same error. I believe the toBuffer() might be returning undefined. That's what happening in my case anyway I think. Also, this happens when I pass null.

I get roughly the same error. I believe the toBuffer() might be returning undefined. That's what happening in my case anyway I think. Also, this happens when I pass null.

@katspaugh katspaugh closed this Jan 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment