support gif frame brackets in filename when using streams too

master
Evan Owen 13 years ago committed by Aaron Heckmann
parent 9945682428
commit 0d1cf5a8f1
  1. 9
      index.js
  2. 4
      lib/command.js
  3. 12
      test/gifFrame.js
  4. 12
      test/gifFrameStream.js

@ -42,6 +42,15 @@ function gm (source, height, color) {
}
// parse out gif frame brackets from filename
// since stream doesn't use source path
// eg. "filename.gif[0]"
var frames;
if(frames = source.match(/(\[.+\])$/)) {
this.sourceFrames = source.substr(frames.index, frames[0].length);
source = source.substr(0, frames.index);
}
this.source = source;
}

@ -163,10 +163,12 @@ module.exports = function (proto) {
}
proto.args = function args () {
var source = (this.sourceStream ? "-" : this.source);
if(source && this.sourceFrames) source += this.sourceFrames;
return [].concat(
'convert'
, this._in
, this.sourceStream ? "-" : this.source
, source
, this._out
, this.outname || "-"
).filter(function(arg) { return !!arg });

@ -0,0 +1,12 @@
// gm - Copyright Aaron Heckmann <aaron.heckmann+github@gmail.com> (MIT Licensed)
var fs = require('fs');
module.exports = function (_, dir, finish, gm) {
gm(dir + '/original.gif[0]')
.write(dir + '/gifFrame.jpg', function gifFrame (err){
finish(err);
});
}

@ -0,0 +1,12 @@
// gm - Copyright Aaron Heckmann <aaron.heckmann+github@gmail.com> (MIT Licensed)
var fs = require('fs');
module.exports = function (_, dir, finish, gm) {
gm(fs.createReadStream(dir + '/original.gif'), "original.gif[0]")
.write(dir + '/gifFrameStream.jpg', function gifFrame (err){
finish(err);
});
}
Loading…
Cancel
Save