mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-15 04:40:02 +01:00
Made Requested Changes
This commit is contained in:
22295
dist/image-sequencer.js
vendored
22295
dist/image-sequencer.js
vendored
File diff suppressed because it is too large
Load Diff
1
examples/images/IS-QR.js
Normal file
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
BIN
examples/images/IS-QR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
@@ -24,6 +24,7 @@
|
||||
"fisheyegl": "^0.1.2",
|
||||
"font-awesome": "~4.5.0",
|
||||
"jquery": "~2",
|
||||
"jsqr": "^0.2.2",
|
||||
"urify": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -9,5 +9,6 @@ module.exports = {
|
||||
'invert': require('./modules/Invert/Module'),
|
||||
'crop': require('./modules/Crop/Module'),
|
||||
'segmented-colormap': require('./modules/SegmentedColormap/Module'),
|
||||
'decode-qr': require('./modules/DecodeQr/Module'),
|
||||
'fisheye-gl': require('./modules/FisheyeGl/Module')
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ module.exports = function Crop(input,options,callback) {
|
||||
pixels.shape = [w,h,4];
|
||||
pixels.stride[1] = 4*w;
|
||||
|
||||
options.format = input.format;
|
||||
|
||||
var chunks = [];
|
||||
var totalLength = 0;
|
||||
var r = savePixels(pixels, options.format);
|
||||
|
||||
36
src/modules/DecodeQr/Module.js
Normal file
36
src/modules/DecodeQr/Module.js
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ require('../src/ImageSequencer.js');
|
||||
//require image files as DataURLs so they can be tested alike on browser and Node.
|
||||
var sequencer = ImageSequencer({ ui: false });
|
||||
|
||||
var test_png = require('../examples/images/test.png.js');
|
||||
var test_gif = require('../examples/images/test.gif.js');
|
||||
var qr = require('./images/IS-QR.js');
|
||||
var test_png = require('./images/test.png.js');
|
||||
var test_gif = require('./images/test.gif.js');
|
||||
|
||||
sequencer.loadImages(test_png);
|
||||
sequencer.addSteps(['do-nothing-pix','invert','invert']);
|
||||
@@ -32,6 +33,19 @@ test("Twice inverted image is identical to original image", function (t) {
|
||||
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) {
|
||||
sequencer.loadImages(test_png,function(){
|
||||
this.addSteps('invert').run(function(out){
|
||||
|
||||
@@ -42,10 +42,18 @@ test('loadImages loads a DataURL image and creates a step.', function (t){
|
||||
|
||||
if(!sequencer.options.inBrowser)
|
||||
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(){
|
||||
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();
|
||||
require('dns').resolve('www.github.com', function(err) {
|
||||
if (err) {
|
||||
console.log("Test aborted due to no internet");
|
||||
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
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
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
1
test/images/test.png.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user