Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it actually does something helpful now :) we may call append with string arguments, each being another image to append to the original source image. if a boolean `true` is passed, the images will be appended left-to-right, otherwise top-to-bottom. Examples: img = gm(src); // +append means left-to-right img.append(img1, img2) gm convert src img1 img2 -append img.append(img, true) gm convert src img +append img.append(img, false) gm convert src img -append img.append(img) gm convert src img -append img.append(img).append() gm convert src img -append img.append(img).append(true) gm convert src img +append img.append(img).background("#222") gm convert src img -background #222 +append fixes #77
- Loading branch information
Showing
6 changed files
with
160 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var gm = require('../') | ||
, dir = __dirname + '/imgs' | ||
, imgs = 'lost.png original.jpg'.split(' ').map(function (img) { | ||
return dir + '/' + img | ||
}) | ||
, out = dir + '/append.jpg' | ||
|
||
gm(imgs[0]) | ||
.append(imgs[1]) | ||
.append() | ||
.background('#222') | ||
.write(out, function (err) { | ||
if (err) return console.dir(arguments) | ||
console.log(this.outname + " created :: " + arguments[3]) | ||
require('child_process').exec('open ' + out) | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var assert = require('assert') | ||
var out; | ||
|
||
module.exports = function (_, dir, next, gm) { | ||
out = require('path').resolve(dir + '/append.jpg'); | ||
|
||
try { | ||
require('fs').unlinkSync(out); | ||
} catch (_) {} | ||
|
||
gm(dir + '/lost.png') | ||
.append(dir + '/original.jpg') | ||
.append() | ||
.background('#222') | ||
.write(out, function (err) { | ||
if (err) return next(err); | ||
gm(out).size(function (err, size) { | ||
if (err) return next(err); | ||
assert.equal(460, size.width); | ||
assert.equal(280, size.height); | ||
|
||
horizontal(dir, next, gm); | ||
}) | ||
}); | ||
} | ||
|
||
function horizontal (dir, next, gm) { | ||
|
||
gm(dir + '/original.jpg') | ||
.append(dir + '/lost.png', true) | ||
.write(out, function (err) { | ||
if (err) return next(err); | ||
gm(out).size(function (err, size) { | ||
if (err) return next(err); | ||
assert.equal(697, size.width); | ||
assert.equal(155, size.height); | ||
|
||
next(); | ||
}) | ||
}); | ||
|
||
} |