Added outputs, fix modulesInfo

This commit is contained in:
Chinmay Pandhare
2017-08-26 03:27:10 +05:30
parent 38975791ca
commit c7e4ec7c4a
5 changed files with 19616 additions and 19656 deletions

39139
dist/image-sequencer.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,87 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="utf-8">
<title>Image Sequencer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="dist/image-sequencer.css" rel="stylesheet">
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="dist/image-sequencer.js"></script>
<meta http-equiv="refresh" content="0; url=examples/" />
</head>
<body>
<div class="header">
<h1>Image Sequencer</h1>
<h3>
<a href="https://github.com/jywarren/image-sequencer"><i class="fa fa-github"></i></a>
</h3>
</div>
<p style="display:none;" class="spinner"><i class="fa fa-spinner fa-spin"></i></p>
<div class="panels">
<div class="panel ismod-image-select">
<div class="mod-drop">Drag image here</div>
<p class="instructions">Select or drop an image here to begin.</p>
<input id="file-select" type="file" />
</div>
</div>
<div class="mod-new-panel">
<form class="mod-new-panel">
<p class="instructions">Add a new step</p>
<select class="select-module form-control" style="margin-bottom:6px;">
<option value="ndvi-red">NDVI with red filter</option>
<option value="green-channel">Green channel</option>
<option value="plot">Plot with colorbar</option>
<option value="image-threshold">Threshold image</option>
</select>
<p><button class="btn btn-default add-step">Add step</button></p>
</form>
</div>
<div class="log">
<h4>Log</h4>
</div>
<script>
var sequencer;
jQuery(document).ready(function($) {
sequencer = ImageSequencer();
sequencer.loadImage('examples/grid.png');
sequencer.addStep('ndvi-red');
sequencer.addStep('image-threshold');
sequencer.addStep('crop');
//sequencer.addStep('plot');
$('.add-step').click(function(e) {
e.preventDefault();
sequencer.addStep($('.select-module').val());
sequencer.run(sequencer.options.initialImage); // later we might only run this step, if we can fetch the image output from the previous
});
});
</script>
</body>
</html>

View File

@@ -6,7 +6,7 @@ sequencer = ImageSequencer({ui: false});
var program = require('commander');
function exit(message) {
console.log(message);
console.error(message);
process.exit(1);
}
@@ -15,23 +15,54 @@ program
.option('-i, --image [PATH/URL]', 'Input image URL')
.option('-s, --step [step-name]', 'Name of the step to be added.')
.option('-o, --output [PATH]', 'Directory where output will be stored.')
.option('-op, --opions {object}', 'Options for the step')
.parse(process.argv);
// User must input an image.
if(!program.image) exit("Can't read file.")
// User must input an image.
require('fs').access(program.image, function(err){
if(err) exit("Can't read file.")
});
// User must input a step.
if(!program.step || !sequencer.modulesInfo().hasOwnProperty(program.step))
exit("Please name a valid step.");
// If there's no user defined output directory, select a default directory
program.output = program.output || "./output/";
sequencer.loadImages(program.image,function(){
sequencer.addSteps(program.step);
sequencer.run(function(){
sequencer.exportBin(program.output);
console.log("Files will be exported to \""+program.output+"\"");
});
// set sequencer to log module outputs, if any
sequencer.setUI({
onComplete: function(step) {
// get information of outputs
step.info = sequencer.modulesInfo(step.name);
for (var output in step.info.outputs) {
console.log("["+program.step+"]: "+output+" = "+step[output]);
}
}
});
// Finally, if everything is alright, load the image, add the step and run the sequencer.
sequencer.loadImages(program.image,function(){
// Add the step inputted by the user
sequencer.addSteps(program.step);
// Run the sequencer
sequencer.run(function(){
// Export all images as binary files
sequencer.exportBin(program.output);
console.log("Files will be exported to \""+program.output+"\"");
});
});

View File

@@ -47,5 +47,8 @@
"tape": ">=4.7.0",
"tape-run": "^3.0.0"
},
"homepage": "https://github.com/publiclab/image-sequencer"
"homepage": "https://github.com/publiclab/image-sequencer",
"bin": {
"sequencer": "./index.js"
}
}

View File

@@ -182,6 +182,7 @@ ImageSequencer = function ImageSequencer(options) {
function modulesInfo(name) {
var modulesdata = {}
if(name == "load-image") return {};
if(arguments.length==0)
for (var modulename in modules) {
modulesdata[modulename] = modules[modulename][1];