diff --git a/Readme.md b/Readme.md index 956686adf..a53e4d2bb 100644 --- a/Readme.md +++ b/Readme.md @@ -79,14 +79,14 @@ img.dataMode = Image.MODE_MIME | Image.MODE_IMAGE; // Both are tracked If image data is not tracked, and the Image is drawn to an image rather than a PDF canvas, the output will be junk. Enabling mime data tracking has no benefits (only a slow down) unless you are generating a PDF. -### Canvas#createPNGStream() +### Canvas#pngStream() - To create a `PNGStream` simply call `canvas.createPNGStream()`, and the stream will start to emit _data_ events, finally emitting _end_ when finished. If an exception occurs the _error_ event is emitted. + To create a `PNGStream` simply call `canvas.pngStream()`, and the stream will start to emit _data_ events, finally emitting _end_ when finished. If an exception occurs the _error_ event is emitted. ```javascript var fs = require('fs') , out = fs.createWriteStream(__dirname + '/text.png') - , stream = canvas.createPNGStream(); + , stream = canvas.pngStream(); stream.on('data', function(chunk){ out.write(chunk); @@ -99,9 +99,9 @@ stream.on('end', function(){ Currently _only_ sync streaming is supported, however we plan on supporting async streaming as well (of course :) ). Until then the `Canvas#toBuffer(callback)` alternative is async utilizing `eio_custom()`. -### Canvas#createJPEGStream() +### Canvas#jpegStream() -You can likewise create a `JPEGStream` by calling `canvas.createJPEGStream()` with some optional parameters; functionality is otherwise identical to `createPNGStream()`. See `examples/crop.js` for an example. +You can likewise create a `JPEGStream` by calling `canvas.jpegStream()` with some optional parameters; functionality is otherwise identical to `pngStream()`. See `examples/crop.js` for an example. ### Canvas#toBuffer() diff --git a/lib/canvas.js b/lib/canvas.js index 7a1fa9679..b18599c6e 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -116,6 +116,7 @@ Canvas.prototype.getContext = function(contextId){ * @api public */ +Canvas.prototype.pngStream = Canvas.prototype.createPNGStream = function(){ return new PNGStream(this); }; @@ -127,6 +128,7 @@ Canvas.prototype.createPNGStream = function(){ * @api public */ +Canvas.prototype.syncPNGStream = Canvas.prototype.createSyncPNGStream = function(){ return new PNGStream(this, true); }; @@ -139,6 +141,7 @@ Canvas.prototype.createSyncPNGStream = function(){ * @api public */ +Canvas.prototype.jpegStream = Canvas.prototype.createJPEGStream = function(options){ return this.createSyncJPEGStream(options); }; @@ -151,6 +154,7 @@ Canvas.prototype.createJPEGStream = function(options){ * @api public */ +Canvas.prototype.syncJPEGStream = Canvas.prototype.createSyncJPEGStream = function(options){ options = options || {}; return new JPEGStream(this, {