Skip to content

Instantly share code, notes, and snippets.

@yamano
Created February 28, 2016 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamano/2e6679a8850172dd4219 to your computer and use it in GitHub Desktop.
Save yamano/2e6679a8850172dd4219 to your computer and use it in GitHub Desktop.
<!-- node line_image.js input.jpg output.png -->
const HEIGHT = 370;
const WIDTH = 320;
if (process.argv.length < 4) {
console.log('missing argument.');
return;
}
var gm = require('gm').subClass({ imageMagick: true });
gm(process.argv[2])
.fuzz('20%')
.trim()
.resize(HEIGHT, WIDTH)
.extent(HEIGHT, WIDTH)
.fuzz('10%')
.fill('#00000000')
.setDraw('matte', 1, 1, 'floodfill')
.setDraw('matte', 1, WIDTH - 1, 'floodfill')
.setDraw('matte', HEIGHT - 1, 1, 'floodfill')
.setDraw('matte', HEIGHT - 1, WIDTH - 1, 'floodfill')
.write(process.argv[3], function (err) {
if (!err) console.log(process.argv[2] + " -> " + process.argv[3]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment