From 89f9511d5daf9be3db0b92072e7c8da1e87cb318 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sat, 17 Aug 2013 17:21:13 -0700 Subject: [PATCH] added; proto.selectFrame(#). closes #202 --- lib/args.js | 7 +++++++ test/selectFrame.js | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/selectFrame.js diff --git a/lib/args.js b/lib/args.js index 7977f34..27bfccb 100644 --- a/lib/args.js +++ b/lib/args.js @@ -10,6 +10,13 @@ var argsToArray = require('./utils').argsToArray; */ module.exports = function (proto) { + // change the specified frame. + // See #202. + proto.selectFrame = function (frame) { + if (typeof frame === 'number') + this.sourceFrames = '[' + frame + ']'; + return this; + } // define the sub-command to use, http://www.graphicsmagick.org/utilities.html proto.command = proto.subCommand = function subCommand (name){ diff --git a/test/selectFrame.js b/test/selectFrame.js new file mode 100644 index 0000000..0626bb6 --- /dev/null +++ b/test/selectFrame.js @@ -0,0 +1,20 @@ +var assert = require('assert'); +var fs = require('fs') + +module.exports = function (_, dir, finish, gm) { + var m = gm(dir + '/original.gif[0]') + + if (!gm.integration) + return finish(); + + m.identify('%#', function (err, hash1) { + if (err) return finish(err); + + m.selectFrame(2).identify('%#', function (err, hash2) { + if (err) return finish(err); + + assert.ok(hash1.toString().trim() !== hash2.toString().trim()) + finish(); + }) + }) +} \ No newline at end of file