mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
Make progress bars on UI true (#1112)
* Make progress bars on UI true Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * update docs Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fix typo Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
committed by
Jeffrey Warren
parent
f5d7b0ae09
commit
80cb5b1194
@@ -280,6 +280,8 @@ module.exports = function ModuleName(options,UI) {
|
|||||||
|
|
||||||
The `progressObj` parameter of `draw()` is not consumed unless a custom progress bar needs to be drawn, for which this default spinner should be stopped with `progressObj.stop()` and image-sequencer is informed about the custom progress bar with `progressObj.overrideFlag = true;` following which this object can be overriden with custom progress object.
|
The `progressObj` parameter of `draw()` is not consumed unless a custom progress bar needs to be drawn, for which this default spinner should be stopped with `progressObj.stop()` and image-sequencer is informed about the custom progress bar with `progressObj.overrideFlag = true;` following which this object can be overriden with custom progress object.
|
||||||
|
|
||||||
|
The pixelManipulation API can draw progress bars internally using the `pace` npm package. The option is disabled by default but can be enabled by passing `ui: true` in the options for pixelManipulation. The recommended way is to use `ui: options.step.ui`. This will only show the progress if the ui is set to true by the user, while creating the sequencer object.
|
||||||
|
|
||||||
### Module example
|
### Module example
|
||||||
|
|
||||||
See existing module `channel` for an example: https://github.com/publiclab/image-sequencer/blob/main/src/modules/Channel/Module.js
|
See existing module `channel` for an example: https://github.com/publiclab/image-sequencer/blob/main/src/modules/Channel/Module.js
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
require('./src/ImageSequencer');
|
require('./src/ImageSequencer');
|
||||||
sequencer = ImageSequencer({ ui: false });
|
sequencer = ImageSequencer({ ui: true });
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var program = require('commander');
|
var program = require('commander');
|
||||||
var utils = require('./src/CliUtils');
|
var utils = require('./src/CliUtils');
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module.exports = function AddQR(options, UI) {
|
|||||||
|
|
||||||
var step = this;
|
var step = this;
|
||||||
|
|
||||||
return getPixels(input.src, function (err, oldPixels) {
|
return getPixels(input.src, function(err, oldPixels) {
|
||||||
function changePixel(r, g, b, a) {
|
function changePixel(r, g, b, a) {
|
||||||
return [r, g, b, a];
|
return [r, g, b, a];
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,7 @@ module.exports = function AddQR(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ module.exports = function Average(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ module.exports = function Dynamic(options, UI, util) {
|
|||||||
// run PixelManipulatin on second image's pixels
|
// run PixelManipulatin on second image's pixels
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ module.exports = function Blur(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ module.exports = function Brightness(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui, //don't pass this in if you don't want your module to support progress bars
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ module.exports = function canvasResize(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ module.exports = function Channel(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ module.exports = function ColorTemperature(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ module.exports = function Colormap(options, UI) {
|
|||||||
}
|
}
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ module.exports = function Contrast(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ module.exports = function Convolution(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ module.exports = function DoNothing(options, UI) {
|
|||||||
|
|
||||||
var step = this;
|
var step = this;
|
||||||
|
|
||||||
getPixels(input.src, function(err, pixels){
|
getPixels(input.src, function(err, pixels) {
|
||||||
|
|
||||||
if(err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
var w = pixels.shape[0];
|
var w = pixels.shape[0];
|
||||||
var h = pixels.shape[1];
|
var h = pixels.shape[1];
|
||||||
@@ -28,7 +28,7 @@ module.exports = function DoNothing(options, UI) {
|
|||||||
options.step.qrval = (decoded) ? decoded.data : 'undefined';
|
options.step.qrval = (decoded) ? decoded.data : 'undefined';
|
||||||
});
|
});
|
||||||
|
|
||||||
function output(image, datauri, mimetype){
|
function output(image, datauri, mimetype) {
|
||||||
// This output is accessible by Image Sequencer
|
// This output is accessible by Image Sequencer
|
||||||
step.output = {
|
step.output = {
|
||||||
src: datauri,
|
src: datauri,
|
||||||
@@ -37,6 +37,7 @@ module.exports = function DoNothing(options, UI) {
|
|||||||
}
|
}
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
callback: callback
|
callback: callback
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
module.exports = function Dither(options, UI){
|
module.exports = function Dither(options, UI) {
|
||||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||||
var output;
|
var output;
|
||||||
|
|
||||||
function draw(input, callback, progressObj){
|
function draw(input, callback, progressObj) {
|
||||||
|
|
||||||
progressObj.stop(true);
|
progressObj.stop(true);
|
||||||
progressObj.overrideFlag = true;
|
progressObj.overrideFlag = true;
|
||||||
@@ -15,7 +15,7 @@ module.exports = function Dither(options, UI){
|
|||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
function output(image, datauri, mimetype){
|
function output(image, datauri, mimetype) {
|
||||||
// This output is accessible by Image Sequencer
|
// This output is accessible by Image Sequencer
|
||||||
step.output = { src: datauri, format: mimetype };
|
step.output = { src: datauri, format: mimetype };
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ module.exports = function Dither(options, UI){
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ module.exports = function DrawRectangle(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ module.exports = function Dynamic(options, UI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Functions to get the neighbouring pixel by position (x,y) */
|
/* Functions to get the neighbouring pixel by position (x,y) */
|
||||||
function getNeighbourPixel(pixels, curX, curY, distX, distY){
|
function getNeighbourPixel(pixels, curX, curY, distX, distY) {
|
||||||
return [
|
return [
|
||||||
pixels.get(curX + distX, curY + distY, 0),
|
pixels.get(curX + distX, curY + distY, 0),
|
||||||
pixels.get(curX + distX, curY + distY, 1),
|
pixels.get(curX + distX, curY + distY, 1),
|
||||||
@@ -71,7 +71,7 @@ module.exports = function Dynamic(options, UI) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function output(image, datauri, mimetype){
|
function output(image, datauri, mimetype) {
|
||||||
|
|
||||||
// This output is accessible by Image Sequencer
|
// This output is accessible by Image Sequencer
|
||||||
step.output = { src: datauri, format: mimetype };
|
step.output = { src: datauri, format: mimetype };
|
||||||
@@ -79,6 +79,7 @@ module.exports = function Dynamic(options, UI) {
|
|||||||
}
|
}
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
getNeighbourPixel: getNeighbourPixel,
|
getNeighbourPixel: getNeighbourPixel,
|
||||||
getNeighborPixel: getNeighbourPixel,
|
getNeighborPixel: getNeighbourPixel,
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ module.exports = function edgeDetect(options, UI) {
|
|||||||
|
|
||||||
// Blur the image
|
// Blur the image
|
||||||
const internalSequencer = ImageSequencer({ inBrowser: false, ui: false });
|
const internalSequencer = ImageSequencer({ inBrowser: false, ui: false });
|
||||||
return internalSequencer.loadImage(input.src, function () {
|
return internalSequencer.loadImage(input.src, function() {
|
||||||
internalSequencer.importJSON([{ 'name': 'blur', 'options': {blur: options.blur} }]);
|
internalSequencer.importJSON([{ 'name': 'blur', 'options': { blur: options.blur } }]);
|
||||||
return internalSequencer.run(function onCallback(internalOutput) {
|
return internalSequencer.run(function onCallback(internalOutput) {
|
||||||
require('get-pixels')(internalOutput, function(err, blurPixels){
|
require('get-pixels')(internalOutput, function(err, blurPixels) {
|
||||||
if (err){
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ module.exports = function edgeDetect(options, UI) {
|
|||||||
return [(r + g + b) / 3, (r + g + b) / 3, (r + g + b) / 3, a];
|
return [(r + g + b) / 3, (r + g + b) / 3, (r + g + b) / 3, a];
|
||||||
}
|
}
|
||||||
|
|
||||||
function extraManipulation(){
|
function extraManipulation() {
|
||||||
return require('./EdgeUtils')(blurPixels, options.highThresholdRatio, options.lowThresholdRatio, options.hysteresis);
|
return require('./EdgeUtils')(blurPixels, options.highThresholdRatio, options.lowThresholdRatio, options.hysteresis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +44,7 @@ module.exports = function edgeDetect(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
* Changes the Image Exposure
|
* Changes the Image Exposure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = function Exposure(options, UI){
|
module.exports = function Exposure(options, UI) {
|
||||||
|
|
||||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||||
var output;
|
var output;
|
||||||
|
|
||||||
function draw(input, callback, progressObj){
|
function draw(input, callback, progressObj) {
|
||||||
|
|
||||||
options.exposure = options.exposure || defaults.exposure;
|
options.exposure = options.exposure || defaults.exposure;
|
||||||
var exposure = Math.pow(2, options.exposure);
|
var exposure = Math.pow(2, options.exposure);
|
||||||
@@ -16,7 +16,7 @@ module.exports = function Exposure(options, UI){
|
|||||||
|
|
||||||
var step = this;
|
var step = this;
|
||||||
|
|
||||||
function changePixel(r, g, b, a){
|
function changePixel(r, g, b, a) {
|
||||||
|
|
||||||
r = Math.min(255, r * exposure);
|
r = Math.min(255, r * exposure);
|
||||||
g = Math.min(255, g * exposure);
|
g = Math.min(255, g * exposure);
|
||||||
@@ -24,15 +24,16 @@ module.exports = function Exposure(options, UI){
|
|||||||
return [r, g, b, a];
|
return [r, g, b, a];
|
||||||
}
|
}
|
||||||
|
|
||||||
function output(image, datauri, mimetype){
|
function output(image, datauri, mimetype) {
|
||||||
|
|
||||||
// This output is accessible by Image Sequencer
|
// This output is accessible by Image Sequencer
|
||||||
step.output = {src:datauri, format:mimetype};
|
step.output = { src: datauri, format: mimetype };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ module.exports = function FlipImage(options, UI) {
|
|||||||
|
|
||||||
var step = this;
|
var step = this;
|
||||||
|
|
||||||
return getPixels(input.src, function(err, oldPixels){
|
return getPixels(input.src, function(err, oldPixels) {
|
||||||
function changePixel(r, g, b, a) {
|
function changePixel(r, g, b, a) {
|
||||||
return [r, g, b, a];
|
return [r, g, b, a];
|
||||||
}
|
}
|
||||||
function extraManipulation(pixels) {
|
function extraManipulation(pixels) {
|
||||||
if (err){
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,7 @@ module.exports = function FlipImage(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ module.exports = function Gamma(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ module.exports = function GridOverlay(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ module.exports = function Channel(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ module.exports = function Ndvi(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
module.exports = function NoiseReduction(options, UI){
|
module.exports = function NoiseReduction(options, UI) {
|
||||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||||
var output;
|
var output;
|
||||||
|
|
||||||
function draw(input,callback,progressObj){
|
function draw(input, callback, progressObj) {
|
||||||
|
|
||||||
progressObj.stop(true);
|
progressObj.stop(true);
|
||||||
progressObj.overrideFlag = true;
|
progressObj.overrideFlag = true;
|
||||||
@@ -15,7 +15,7 @@ module.exports = function NoiseReduction(options, UI){
|
|||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
function output(image, datauri, mimetype){
|
function output(image, datauri, mimetype) {
|
||||||
// This output is accessible by Image Sequencer
|
// This output is accessible by Image Sequencer
|
||||||
step.output = { src: datauri, format: mimetype };
|
step.output = { src: datauri, format: mimetype };
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ module.exports = function NoiseReduction(options, UI){
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ module.exports = function Dynamic(options, UI, util) {
|
|||||||
// run PixelManipulation on first Image pixels
|
// run PixelManipulation on first Image pixels
|
||||||
return require('../_nomodule/PixelManipulation.js')(baseStepOutput, {
|
return require('../_nomodule/PixelManipulation.js')(baseStepOutput, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: baseStepOutput.format,
|
format: baseStepOutput.format,
|
||||||
image: baseStepImage,
|
image: baseStepImage,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ module.exports = function PaintBucket(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ module.exports = function ReplaceColor(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ module.exports = function Resize(options, UI) {
|
|||||||
new_width = Math.round(pixels.shape[0] * (resize_value / 100));
|
new_width = Math.round(pixels.shape[0] * (resize_value / 100));
|
||||||
new_height = Math.round(pixels.shape[1] * (resize_value / 100));
|
new_height = Math.round(pixels.shape[1] * (resize_value / 100));
|
||||||
|
|
||||||
var bitmap = new imagejs.Bitmap({width: pixels.shape[0], height: pixels.shape[1]});
|
var bitmap = new imagejs.Bitmap({ width: pixels.shape[0], height: pixels.shape[1] });
|
||||||
bitmap._data.data = pixels.data;
|
bitmap._data.data = pixels.data;
|
||||||
|
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ module.exports = function Resize(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ module.exports = function Rotate(options, UI) {
|
|||||||
function extraManipulation(pixels) {
|
function extraManipulation(pixels) {
|
||||||
var rotate_value = (options.rotate) % 360;
|
var rotate_value = (options.rotate) % 360;
|
||||||
|
|
||||||
if(rotate_value % 360 == 0)
|
if (rotate_value % 360 == 0)
|
||||||
return pixels;
|
return pixels;
|
||||||
|
|
||||||
var bitmap = new imagejs.Bitmap({width: pixels.shape[0], height: pixels.shape[1]});
|
var bitmap = new imagejs.Bitmap({ width: pixels.shape[0], height: pixels.shape[1] });
|
||||||
bitmap._data.data = pixels.data;
|
bitmap._data.data = pixels.data;
|
||||||
|
|
||||||
var rotated = bitmap.rotate({
|
var rotated = bitmap.rotate({
|
||||||
@@ -45,6 +45,7 @@ module.exports = function Rotate(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ module.exports = function Saturation(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module.exports = function TextOverlay(options, UI) {
|
|||||||
this.output = input;
|
this.output = input;
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
var priorStep = this.getStep(-1); // get the previous step to add text onto it.
|
var priorStep = this.getStep(-1); // get the previous step to add text onto it.
|
||||||
|
|
||||||
function extraManipulation(pixels) {
|
function extraManipulation(pixels) {
|
||||||
@@ -31,6 +31,7 @@ module.exports = function TextOverlay(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
@@ -48,4 +49,3 @@ module.exports = function TextOverlay(options, UI) {
|
|||||||
UI: UI
|
UI: UI
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ module.exports = function ImageThreshold(options, UI) {
|
|||||||
}
|
}
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ module.exports = function Tint(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
changePixel: changePixel,
|
changePixel: changePixel,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ module.exports = function Balance(options, UI) {
|
|||||||
|
|
||||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||||
output: output,
|
output: output,
|
||||||
|
ui: options.step.ui,
|
||||||
extraManipulation: extraManipulation,
|
extraManipulation: extraManipulation,
|
||||||
format: input.format,
|
format: input.format,
|
||||||
image: options.image,
|
image: options.image,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = function PixelManipulation(image, options) {
|
|||||||
// TODO: this could possibly be more efficient; see
|
// TODO: this could possibly be more efficient; see
|
||||||
// https://github.com/p-v-o-s/infragram-js/blob/master/public/infragram.js#L173-L181
|
// https://github.com/p-v-o-s/infragram-js/blob/master/public/infragram.js#L173-L181
|
||||||
|
|
||||||
if (!options.inBrowser && !process.env.TEST) {
|
if (!options.inBrowser && !process.env.TEST && options.ui) {
|
||||||
try {
|
try {
|
||||||
var pace = require('pace')(pixels.shape[0] * pixels.shape[1]);
|
var pace = require('pace')(pixels.shape[0] * pixels.shape[1]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -63,7 +63,7 @@ module.exports = function PixelManipulation(image, options) {
|
|||||||
pixels.set(x, y, 2, pixel[2]);
|
pixels.set(x, y, 2, pixel[2]);
|
||||||
pixels.set(x, y, 3, pixel[3]);
|
pixels.set(x, y, 3, pixel[3]);
|
||||||
|
|
||||||
if (!options.inBrowser && !process.env.TEST) pace.op();
|
if (!options.inBrowser && !process.env.TEST && options.ui) pace.op();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user