Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add Canvas#{png,jpeg}Stream() alias of create* legacy methods

create* is annoying
  • Loading branch information...
commit 0d39dae66c327e6c18ca00019817007502614259 1 parent 64af9b2
@tj tj authored
Showing with 9 additions and 5 deletions.
  1. +5 −5 Readme.md
  2. +4 −0 lib/canvas.js
View
10 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()
View
4 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, {
Please sign in to comment.
Something went wrong with that request. Please try again.