Made Requested Changes

This commit is contained in:
Chinmay Pandhare
2017-08-06 17:51:54 +05:30
12 changed files with 12664 additions and 9831 deletions

22417
dist/image-sequencer.js vendored

File diff suppressed because it is too large Load Diff

1
examples/images/IS-QR.js Normal file

File diff suppressed because one or more lines are too long

BIN
examples/images/IS-QR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -24,6 +24,7 @@
"fisheyegl": "^0.1.2", "fisheyegl": "^0.1.2",
"font-awesome": "~4.5.0", "font-awesome": "~4.5.0",
"jquery": "~2", "jquery": "~2",
"jsqr": "^0.2.2",
"urify": "^2.1.0" "urify": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -9,5 +9,6 @@ module.exports = {
'invert': require('./modules/Invert/Module'), 'invert': require('./modules/Invert/Module'),
'crop': require('./modules/Crop/Module'), 'crop': require('./modules/Crop/Module'),
'segmented-colormap': require('./modules/SegmentedColormap/Module'), 'segmented-colormap': require('./modules/SegmentedColormap/Module'),
'decode-qr': require('./modules/DecodeQr/Module'),
'fisheye-gl': require('./modules/FisheyeGl/Module') 'fisheye-gl': require('./modules/FisheyeGl/Module')
} }

View File

@@ -17,6 +17,8 @@ module.exports = function Crop(input,options,callback) {
pixels.shape = [w,h,4]; pixels.shape = [w,h,4];
pixels.stride[1] = 4*w; pixels.stride[1] = 4*w;
options.format = input.format;
var chunks = []; var chunks = [];
var totalLength = 0; var totalLength = 0;
var r = savePixels(pixels, options.format); var r = savePixels(pixels, options.format);

View File

@@ -0,0 +1,36 @@
/*
* Decodes QR from a given image.
*/
module.exports = function DoNothing(options,UI) {
options = options || {};
options.title = "Decode QR Code";
UI.onSetup(options.step);
var output;
var jsQR = require('jsqr');
var getPixels = require('get-pixels');
function draw(input,callback) {
UI.onDraw(options.step);
const step = this;
getPixels(input.src,function(err,pixels){
if(err) throw err;
var w = pixels.shape[0];
var h = pixels.shape[1];
var decoded = jsQR.decodeQRFromImage(pixels.data,w,h);
step.output = input;
step.output.data = decoded;
callback();
options.step.output = input.src;
UI.onComplete(options.step);
});
}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}

View File

@@ -10,8 +10,9 @@ require('../src/ImageSequencer.js');
//require image files as DataURLs so they can be tested alike on browser and Node. //require image files as DataURLs so they can be tested alike on browser and Node.
var sequencer = ImageSequencer({ ui: false }); var sequencer = ImageSequencer({ ui: false });
var test_png = require('../examples/images/test.png.js'); var qr = require('./images/IS-QR.js');
var test_gif = require('../examples/images/test.gif.js'); var test_png = require('./images/test.png.js');
var test_gif = require('./images/test.gif.js');
sequencer.loadImages(test_png); sequencer.loadImages(test_png);
sequencer.addSteps(['do-nothing-pix','invert','invert']); sequencer.addSteps(['do-nothing-pix','invert','invert']);
@@ -32,6 +33,19 @@ test("Twice inverted image is identical to original image", function (t) {
t.end(); t.end();
}); });
test("Decode QR module works properly :: setup", function (t) {
sequencer.loadImage(qr,function(){
this.addSteps('decode-qr').run(function(){
t.end();
});
})
});
test("Decode QR module works properly :: teardown", function (t) {
t.equal("http://github.com/publiclab/image-sequencer",sequencer.images.image2.steps[1].output.data);
t.end();
});
test("PixelManipulation works for PNG images", function (t) { test("PixelManipulation works for PNG images", function (t) {
sequencer.loadImages(test_png,function(){ sequencer.loadImages(test_png,function(){
this.addSteps('invert').run(function(out){ this.addSteps('invert').run(function(out){

View File

@@ -42,10 +42,18 @@ test('loadImages loads a DataURL image and creates a step.', function (t){
if(!sequencer.options.inBrowser) if(!sequencer.options.inBrowser)
test('loadImage loads an image from URL and creates a step. (NodeJS)', function (t){ test('loadImage loads an image from URL and creates a step. (NodeJS)', function (t){
sequencer.loadImage('URL','https://ccpandhare.github.io/image-sequencer/examples/images/red.jpg', function(){ require('dns').resolve('www.github.com', function(err) {
t.equal(sequencer.images.URL.steps.length, 1, "Initial Step Created"); if (err) {
t.equal(typeof(sequencer.images.URL.steps[0].output.src), "string", "Initial output exists"); console.log("Test aborted due to no internet");
t.end(); t.end();
}
else {
sequencer.loadImage('URL','https://ccpandhare.github.io/image-sequencer/examples/images/red.jpg', function(){
t.equal(sequencer.images.URL.steps.length, 1, "Initial Step Created");
t.equal(typeof(sequencer.images.URL.steps[0].output.src), "string", "Initial output exists");
t.end();
});
}
}); });
}); });

1
test/images/IS-QR.js Normal file

File diff suppressed because one or more lines are too long

1
test/images/test.gif.js Normal file

File diff suppressed because one or more lines are too long

1
test/images/test.png.js Normal file

File diff suppressed because one or more lines are too long