Added montage()

master
Donald Cook 10 years ago
parent 2fb65bac7c
commit 9efaf3277c
  1. 17
      README.md
  2. 1
      index.js
  3. 27
      lib/montage.js
  4. 20
      test/montage.js

@ -563,6 +563,23 @@ gm('/path/to/image.jpg')
});
```
##montage
GraphicsMagick supports montage for combining images side by side. This is exposed through `gm.montage()`. Its only argument is an image path with the changes to the base image.
Currently, `gm.montage()` only accepts file paths.
gm.montage(other)
```js
gm('/path/to/image.jpg')
.montage('/path/to/second_image.jpg')
.geometry('+100+150')
.write('/path/to/montage.png', function(err) {
if(!err) console.log("Written montage image.");
});
```
## Contributors
[https://github.com/aheckmann/gm/contributors](https://github.com/aheckmann/gm/contributors)

@ -117,6 +117,7 @@ require("./lib/convenience")(gm.prototype);
require("./lib/command")(gm.prototype);
require("./lib/compare")(gm.prototype);
require("./lib/composite")(gm.prototype);
require("./lib/montage")(gm.prototype);
/**
* Expose.

@ -0,0 +1,27 @@
// montage
var exec = require('child_process').exec;
var utils = require('./utils');
/**
* Montage images next to each other using the `montage` command in graphicsmagick.
*
* gm('/path/to/image.jpg')
* .montage('/path/to/second_image.jpg')
* .geometry('+100+150')
* .write('/path/to/montage.png', function(err) {
* if(!err) console.log("Written montage image.");
* });
*
* @param {String} other Path to the image that contains the changes.
*/
module.exports = exports = function(proto) {
proto.montage = function(other) {
this.in(other);
this.subCommand("montage");
return this;
}
}

@ -0,0 +1,20 @@
var assert = require('assert')
module.exports = function (gm, dir, finish, GM) {
gm.source = __dirname + '/fixtures/compare_1.png';
var a = gm.montage(__dirname + '/fixtures/favicon.png')
var args = a.args();
assert.equal('montage', args[0]);
assert.equal(__dirname + '/fixtures/favicon.png', args[1]);
assert.equal(__dirname + '/fixtures/compare_1.png', args[2]);
if (!GM.integration)
return finish();
a
.write(dir + '/montage.png', function(err) {
finish(err);
});
}
Loading…
Cancel
Save