Skip to content

Instantly share code, notes, and snippets.

@memorycraft
Created February 10, 2014 22:01
Show Gist options
  • Save memorycraft/8925118 to your computer and use it in GitHub Desktop.
Save memorycraft/8925118 to your computer and use it in GitHub Desktop.
gm:合成処理のモジュール化
//合成処理のモジュール化
var spawn = require('child_process').spawn
var fs = require('fs');
//子プロセスで処理
var gmcomposite = function(change_path, base_path, mask_path, output_path, callback) {
var c = spawn('gm', ['composite', '-quality', 100, '-geometry', '+0+0', change_path, base_path, output_path]);
c.stderr.on('data', function(data) {
console.log('stderr: ' + data);
})
c.on('exit', function(code) {
if (code !== 0) callback(code, null)
else callback(null, null)
})
};
//モジュール出力
module.exports = gmcomposite;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment