Browse Source

updated documentation for createJPEGStream

v1.x
Elijah Hamovitz 13 years ago
committed by Tj Holowaychuk
parent
commit
93f2145823
  1. 6
      Readme.md
  2. 9
      lib/canvas.js

6
Readme.md

@ -66,7 +66,7 @@ ctx.drawImage(img, 100, 0, 50, 50);
### Canvas#createPNGStream()
To create a `PNGStream` simple 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.createPNGStream()`, 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')
@ -84,6 +84,10 @@ 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()
You can likewise create a `JPEGStream` by calling `canvas.createJPEGStream()` with the optional parameters `bufsize` and `quality`; functionality is otherwise identical to `createPNGStream()`. See `examples/crop.js` for an example.
### Canvas#toBuffer()
A call to `Canvas#toBuffer()` will return a node `Buffer` instance containing all of the PNG data.

9
lib/canvas.js

@ -118,6 +118,7 @@ Canvas.prototype.createSyncPNGStream = function(){
/**
* Create a `JPEGStream` for `this` canvas.
*
* @param {Object} [opts] Can optionally contain bufsize or quality settings
* @return {JPEGStream}
* @api public
*/
@ -134,11 +135,17 @@ Canvas.prototype.createJPEGStream = function(opts){
/**
* Create a synchronous `JPEGStream` for `this` canvas.
*
* @param {Object} [opts] Can optionally contain bufsize or quality settings
* @return {JPEGStream}
* @api public
*/
Canvas.prototype.createSyncJPEGStream = function(){
Canvas.prototype.createSyncJPEGStream = function(opts){
opts = opts || {};
options = {
bufsize : opts.bufsize || 4096,
quality : opts.quality || 60,
};
return new JPEGStream(this, options, true);
};

Loading…
Cancel
Save