Skip to content

Commit

Permalink
wrap old stream
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindfjeldstad committed Apr 1, 2013
1 parent 58c9dc0 commit f577365
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1 +1,2 @@
.DS_Store
.DS_Store
node_modules
11 changes: 10 additions & 1 deletion index.js
@@ -1,11 +1,14 @@
var spawn = require('child_process').spawn
, Duplex = require('stream').Duplex
, stream = require('stream')
, Duplex = stream.Duplex
, Readable = stream.Readable
, isError = require('util').isError
, fs = require('fs');


// Node pre v0.10.0 comp.
if (!Duplex) Duplex = require('readable-stream').Duplex;
if (!Readable) Readable = require('readable-stream').Readable;

function ImageMagick (src) {
if (!(this instanceof ImageMagick))
Expand Down Expand Up @@ -158,6 +161,12 @@ function _spawn () {
var proc = spawn('convert', this.args);

var stdout = proc.stdout;

if (!stdout.read) {
stdout = new Readable();
stdout.wrap(proc.stdout);
}

stdout.on('end', this.push.bind(this, null));
stdout.on('readable', this.read.bind(this, 0));
stdout.on('error', onerror);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "imagemagick-stream",
"version": "0.0.2",
"version": "0.0.3",
"description": "Streaming Imagemagick api",
"keywords": ["stream", "imagemagick", "thumbnail"],
"author": "Eivind Fjeldstad",
Expand Down

0 comments on commit f577365

Please sign in to comment.