Skip to content

Instantly share code, notes, and snippets.

@JixunMoe JixunMoe/README.MD
Last active Jul 22, 2016

Embed
What would you like to do?
Merge ntr-cfw screenshots

NTR CFW 截图合并脚本

合并 NTR CFW 在 3DS 截图产生的 top_xxxx.bmpbot_xxxx.bmp 至一个文件。

详细阅读:Jixun.Moe

使用前提

控制台/终端 执行 convert -version 能输出 ImageMagick 的信息。

如果没有,请:

  • Windows 用户请执行 SET "PATH=DIR_TO_IMAGEMAGICK;%PATH%"
  • Linux / Mac 用户请安装 ImageMagick 的软件包。

使用指令

$ node ntr_merge.js [[source dir] output dir]

Params:
source dir: Default to "current directory"
output dir: Default to "source dir/out"
/**
* ntr screenshot merger.
* Windows: Ensure directory of `convert.exe` is prepend to %PATH% before execute.
* Linux/Mac: Install ImageMagick Package.
*
* @author Jixun<https://jixun.moe/>
* @license MIT License<https://opensource.org/licenses/MIT>
*/
/* jshint esnext:true */
const fs = require('fs');
const path = require('path');
const exec = require('child_process').execSync;
let dir = process.argv[2] || process.cwd();
let outDir = process.argv[3] || path.join(dir, 'out');
let names = fs.readdirSync(dir);
if (!fs.existsSync(outDir))
fs.mkdirSync(outDir);
names.forEach(name => {
let m = name.match(/^top_(\d{4})\.bmp$/i);
if (m) {
let in_top = path.join(dir, name);
let in_bot = path.join(dir, `bot_${m[1]}.bmp`);
let output = path.join(outDir, `${m[1]}.png`);
console.info(`Merge image ${m[1]} ...`);
exec(`convert "${in_top}" -background black "${in_bot}" -gravity center -append "${output}"`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.