Skip to content
Browse files

fixed; use of Buffers with identify()

  • Loading branch information...
1 parent 66cc0e0 commit 2bdbbd55a304037e8e4ab938a515c1a9429e9155 @aheckmann committed Dec 14, 2012
Showing with 9 additions and 4 deletions.
  1. +6 −1 index.js
  2. +2 −2 lib/command.js
  3. +1 −1 lib/getters.js
View
7 index.js
@@ -35,6 +35,9 @@ function gm (source, height, color) {
if (source instanceof Stream) {
this.sourceStream = source;
source = height || 'unknown.jpg';
+ } else if (Buffer.isBuffer(source)) {
+ this.sourceBuffer = source;
+ source = height || 'unknown.jpg';
} else if (height) {
// new images
width = source;
@@ -64,10 +67,12 @@ function gm (source, height, color) {
this.addSrcFormatter(function (src) {
// must be first source formatter
- var inputFromStdin = this.sourceStream || Buffer.isBuffer(this.source);
+ var inputFromStdin = this.sourceStream || this.sourceBuffer;
var ret = inputFromStdin ? '-' : this.source;
+
if (ret && this.sourceFrames) ret += this.sourceFrames;
+
src.length = 0;
src[0] = ret;
});
View
4 lib/command.js
@@ -183,8 +183,8 @@ module.exports = function (proto) {
debug(cmd);
- if (Buffer.isBuffer(this.source)) {
- proc.stdin.write(this.source);
+ if (this.sourceBuffer) {
+ proc.stdin.write(this.sourceBuffer);
proc.stdin.end();
} else if (self.sourceStream) {
View
2 lib/getters.js
@@ -232,7 +232,7 @@ module.exports = function (gm) {
args.push('-verbose');
}
- args.push(self.sourceStream ? '-' : self.source);
+ args.push(self.sourceStream || self.sourceBuffer ? '-' : self.source);
return args;
}

0 comments on commit 2bdbbd5

Please sign in to comment.
Something went wrong with that request. Please try again.