Colorbar added (#316)

* setup

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* overlay done

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add colorbar fixes #285

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add inputs to colorbar

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
Varun Gupta
2018-08-06 21:23:08 +05:30
committed by Jeffrey Warren
parent 43e6253095
commit e15e981d0b
13 changed files with 501 additions and 53 deletions

View File

@@ -0,0 +1,62 @@
module.exports = function Invert(options, UI) {
var output;
// The function which is called on every draw.
function draw(input, callback, progressObj) {
var getPixels = require('get-pixels');
var savePixels = require('save-pixels');
var step = this;
getPixels(input.src, function(err, pixels) {
if (err) {
console.log("Bad Image path");
return;
}
var width = 0;
for (var i = 0; i < pixels.shape[0]; i++) width++;
for (var i = 0; i < pixels.shape[0]; i++) {
for (var j = 0; j < pixels.shape[1]; j++) {
let val = (i / width) * 255;
pixels.set(i, j, 0, val);
pixels.set(i, j, 1, val);
pixels.set(i, j, 2, val);
pixels.set(i, j, 3, 255);
}
}
var chunks = [];
var totalLength = 0;
var r = savePixels(pixels, input.format, { quality: 100 });
r.on("data", function(chunk) {
totalLength += chunk.length;
chunks.push(chunk);
});
r.on("end", function() {
var data = Buffer.concat(chunks, totalLength).toString("base64");
var datauri = "data:image/" + input.format + ";base64," + data;
output(input.image, datauri, input.format);
callback();
});
});
function output(image, datauri, mimetype) {
// This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype };
}
}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}