mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
Merge branch 'main' into fisheye
This commit is contained in:
@@ -78,7 +78,8 @@ This module is used for averaging all the pixels of the image.
|
||||
|
||||
## blend-module
|
||||
|
||||
This module is used for blending two images .
|
||||
This module is used for blending two images. For More info read: _[wiki](https://en.wikipedia.org/wiki/Blend_modes)_
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
@@ -88,8 +89,12 @@ This module is used for blending two images .
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* offset: step of image with which current image is to be blended(Two steps back is -2, three steps back is -3 etc; default -2)
|
||||
* func: function used to blend two images (default : function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] })
|
||||
* offset: step of image with which current image is to be blended(Two steps back is -2, three steps back is -3 etc; default -2)
|
||||
* blendMode: Blending mode to use for blending two images by default it uses the given function
|
||||
* func: function used to blend two images (default : function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] })
|
||||
|
||||
[More info for different blend modes can be found here](http://docs.gimp.org/en/gimp-concepts-layer-modes.html)
|
||||
|
||||
|
||||
## Blob Analysis
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ var defaultHtmlSequencerUi = require('./lib/defaultHtmlSequencerUi.js'),
|
||||
DefaultHtmlStepUi = require('./lib/defaultHtmlStepUi.js'),
|
||||
urlHash = require('./lib/urlHash.js'),
|
||||
insertPreview = require('./lib/insertPreview.js'),
|
||||
versionManagement = require('./lib/versionManagement.js');
|
||||
versionManagement = require('./lib/versionManagement.js'),
|
||||
isGIF = require('../src/util/isGif');
|
||||
|
||||
|
||||
window.onload = function () {
|
||||
@@ -270,8 +271,8 @@ window.onload = function () {
|
||||
* @param {string} imageDataURL - The data URL for the image.
|
||||
*/
|
||||
function savePDF(imageDataURL) {
|
||||
sequencer.getImageDimensions(imageDataURL, function(dimensions, isGIF) {
|
||||
if (!isGIF) {
|
||||
sequencer.getImageDimensions(imageDataURL, function(dimensions) {
|
||||
if (isGIF(imageDataURL)) {
|
||||
// Get the dimensions of the image.
|
||||
let pageWidth = dimensions.width;
|
||||
let pageHeight = dimensions.height;
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
A pure JavaScript sequential image processing system, inspired by storyboards. Instead of modifying the original
|
||||
image, it
|
||||
creates a new image at each step in a sequence.
|
||||
<a href="https://publiclab.org/image-sequencer">Learn more</a>
|
||||
<a href="https://github.com/publiclab/image-sequencer/blob/main/README.md">Learn more</a>
|
||||
</p>
|
||||
<p>
|
||||
Open Source
|
||||
|
||||
@@ -12,7 +12,8 @@ const intermediateHtmlStepUi = require('./intermediateHtmlStepUi.js'),
|
||||
urlHash = require('./urlHash.js'),
|
||||
_ = require('lodash'),
|
||||
mapHtmlTypes = require('./mapHtmltypes'),
|
||||
scopeQuery = require('./scopeQuery');
|
||||
scopeQuery = require('./scopeQuery'),
|
||||
isGIF = require('../../src/util/isGif');
|
||||
|
||||
function DefaultHtmlStepUi(_sequencer, options) {
|
||||
options = options || {};
|
||||
@@ -78,7 +79,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
step.$step = scopeQuery.scopeSelector(step.ui); // Shorthand methods for scoped DOM queries. Read the docs [CONTRIBUTING.md](https://github.com/publiclab/image-sequencer/blob/main/CONTRIBUTING.md) for more info.
|
||||
step.$stepAll = scopeQuery.scopeSelectorAll(step.ui);
|
||||
let {$step, $stepAll} = step;
|
||||
|
||||
|
||||
step.linkElements = step.ui.querySelectorAll('a'); // All the anchor tags in the step UI
|
||||
step.imgElement = $step('a img.img-thumbnail')[0]; // The output image
|
||||
|
||||
@@ -126,7 +127,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
paramVal +
|
||||
'" placeholder ="' +
|
||||
(inputDesc.placeholder || '');
|
||||
|
||||
|
||||
if (inputDesc.type.toLowerCase() == 'range') {
|
||||
html +=
|
||||
'"min="' +
|
||||
@@ -211,7 +212,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
$step('.toggleIcon').toggleClass('rotated');
|
||||
$stepAll('.cal').collapse('toggle');
|
||||
});
|
||||
|
||||
|
||||
$(step.imgElement).on('mousemove', _.debounce(() => imageHover(step), 150)); // Shows the pixel coordinates on hover
|
||||
$(step.imgElement).on('click', (e) => {e.preventDefault(); });
|
||||
$stepAll('#color-picker').colorpicker();
|
||||
@@ -332,7 +333,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
element.setAttribute('download', step.name + '.' + fileExtension(step.imgElement.src));
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
|
||||
|
||||
element.click();
|
||||
});
|
||||
|
||||
@@ -348,7 +349,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
.data('initValue', step.options[i]);
|
||||
if (inputs[i].type.toLowerCase() === 'select')
|
||||
$step('div[name="' + i + '"] select')
|
||||
.val(step.options[i])
|
||||
.val(String(step.options[i]))
|
||||
.data('initValue', step.options[i]);
|
||||
}
|
||||
}
|
||||
@@ -379,8 +380,8 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
*
|
||||
*/
|
||||
function updateDimensions(step){
|
||||
_sequencer.getImageDimensions(step.imgElement.src, function (dim, isGIF) {
|
||||
step.ui.querySelector('.' + step.name).attributes['data-original-title'].value = `<div style="text-align: center"><p>Image Width: ${dim.width}<br>Image Height: ${dim.height}</br>${isGIF ? `Frames: ${dim.frames}` : ''}</div>`;
|
||||
_sequencer.getImageDimensions(step.imgElement.src, function (dim) {
|
||||
step.ui.querySelector('.' + step.name).attributes['data-original-title'].value = `<div style="text-align: center"><p>Image Width: ${dim.width}<br>Image Height: ${dim.height}</br>${isGIF(step.output) ? `Frames: ${dim.frames}` : ''}</div>`;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -418,7 +419,9 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
if (_sequencer.steps.length - 1 > 1) $('#load-image .insert-step').prop('disabled', false);
|
||||
else $('#load-image .insert-step').prop('disabled', true);
|
||||
|
||||
$('div[class*=imgareaselect-]').remove();
|
||||
$(step.imgElement).imgAreaSelect({
|
||||
remove: true
|
||||
});
|
||||
}
|
||||
|
||||
function getPreview() {
|
||||
@@ -438,14 +441,14 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
notification.innerHTML = ' <i class="fa fa-info-circle" aria-hidden="true"></i> ' + msg ;
|
||||
notification.id = id;
|
||||
notification.classList.add('notification');
|
||||
|
||||
|
||||
$('body').append(notification);
|
||||
}
|
||||
|
||||
|
||||
$('#' + id).fadeIn(500).delay(200).fadeOut(500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
getPreview: getPreview,
|
||||
onSetup: onSetup,
|
||||
|
||||
20
package-lock.json
generated
20
package-lock.json
generated
@@ -6307,9 +6307,9 @@
|
||||
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4="
|
||||
},
|
||||
"gl": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/gl/-/gl-4.4.0.tgz",
|
||||
"integrity": "sha512-4FIq5tqiltTsadrLh6DGY4R9+aQwj25OM2WlXEv81N6YN1q1C0qR7ct0SKp1uUJdnBqbKhUJP3zQ1td40AVeJg==",
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/gl/-/gl-4.4.1.tgz",
|
||||
"integrity": "sha512-2ZG8/qUAQ6WRgPzflsiLbx1KBgrKra0T0GJeG6xyxzNYvUOoeFFPIJJZ/e9X089yag+4NcrzD0ql7PfbJCuuqQ==",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"bit-twiddle": "^1.0.2",
|
||||
@@ -6525,12 +6525,12 @@
|
||||
"integrity": "sha512-BmoRk9nbMaxkrwzTJp4M0iuwIbzNEXt6tlBZ5+ZYzaGH9VWu5Nhn1Q1CBusCam3d8u3FfVEFf3Ueo8DocUCbUw=="
|
||||
},
|
||||
"gpu.js": {
|
||||
"version": "2.4.8",
|
||||
"resolved": "https://registry.npmjs.org/gpu.js/-/gpu.js-2.4.8.tgz",
|
||||
"integrity": "sha512-V4CAZIR+kV6enLVPGoeZdb4lK4FGGuolDDYNBMAlNzrfDN7OJjl2V9we6bKDTKhV/gwsYmivs0x22qo/Q0zHzA==",
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/gpu.js/-/gpu.js-2.6.2.tgz",
|
||||
"integrity": "sha512-Ond7t6xGUn4bUC/vzI2D8VgBIharso7LIr66ZvLy01JOUkGLQ2DgSUXZ9gix1iSzZ9e6/EQWcBkHDNehUePbFA==",
|
||||
"requires": {
|
||||
"acorn": "^7.1.0",
|
||||
"gl": "^4.4.0",
|
||||
"gl": "^4.4.1",
|
||||
"gl-wiretap": "^0.6.2",
|
||||
"gpu-mock.js": "^1.1.1"
|
||||
}
|
||||
@@ -14738,9 +14738,9 @@
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
|
||||
"integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz",
|
||||
"integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==",
|
||||
"requires": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
const _ = require('lodash');
|
||||
const _ = require('lodash'),
|
||||
parseCornerCoordinateInputs = require('../../util/ParseInputCoordinates');
|
||||
module.exports = function AddQR(options, UI) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
options.size = options.size || defaults.size;
|
||||
options.qrCodeString = options.qrCodeString || defaults.qrCodeString;
|
||||
var output;
|
||||
getPixels = require('get-pixels');
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
options.size = Number(options.size || defaults.size);
|
||||
options.qrCodeString = options.qrCodeString || defaults.qrCodeString;
|
||||
options.startingX = options.startingX || defaults.startingX;
|
||||
options.startingY = options.startingY || defaults.startingY;
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
@@ -19,9 +22,21 @@ module.exports = function AddQR(options, UI) {
|
||||
}
|
||||
|
||||
function extraManipulation(pixels, setRenderState, generateOutput) {
|
||||
let iw = pixels.shape[0], // Width of Original Image
|
||||
ih = pixels.shape[1]; // Height of Original Image
|
||||
const oldPixels = _.cloneDeep(pixels);
|
||||
setRenderState(false); // Prevent rendering of final output image until extraManipulation completes.
|
||||
|
||||
// Parse the inputs.
|
||||
parseCornerCoordinateInputs({iw, ih},
|
||||
{
|
||||
startingX: { valInp: options.startingX, type: 'horizontal'},
|
||||
startingY: { valInp: options.startingY, type: 'vertical' },
|
||||
}, function(opt, cord){
|
||||
options.startingX = Math.floor(cord.startingX.valInp);
|
||||
options.startingY = Math.floor(cord.startingY.valInp);
|
||||
});
|
||||
|
||||
require('./QR')(options, pixels, oldPixels, () => {
|
||||
setRenderState(true); // Allow rendering in the callback.
|
||||
generateOutput();
|
||||
|
||||
@@ -12,11 +12,11 @@ module.exports = exports = function (options, pixels, oldPixels, cb) {
|
||||
const width = oldPixels.shape[0],
|
||||
height = oldPixels.shape[1];
|
||||
|
||||
const xe = width - options.size, // Starting pixel coordinates
|
||||
ye = height - options.size;
|
||||
|
||||
for (let x = xe; x < width; x++) {
|
||||
for (let y = ye; y < height; y++) {
|
||||
const xe = Math.min(options.startingX, width - options.size), // Starting pixel coordinates
|
||||
ye = Math.min(options.startingY, height - options.size);
|
||||
|
||||
for (let x = xe; x < Math.min(xe + options.size, width); x++) {
|
||||
for (let y = ye; y < Math.min(ye + options.size, height); y++) {
|
||||
pixelSetter(
|
||||
x,
|
||||
y,
|
||||
|
||||
@@ -12,6 +12,16 @@
|
||||
"type": "string",
|
||||
"desc": "input string to generate QR code",
|
||||
"default": "https://github.com/publiclab/image-sequencer"
|
||||
},
|
||||
"startingX": {
|
||||
"type": "string",
|
||||
"desc": "X-position (measured from left) from where QR starts",
|
||||
"default": "0"
|
||||
},
|
||||
"startingY": {
|
||||
"type": "string",
|
||||
"desc": "Y-position (measured from top) from where QR starts",
|
||||
"default": "0"
|
||||
}
|
||||
},
|
||||
"docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#add-qr-module"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
module.exports = function Dynamic(options, UI, util) {
|
||||
module.exports = function Blend(options, UI, util) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
|
||||
options.func = options.func || defaults.blend;
|
||||
options.func = options.blend || defaults.blend;
|
||||
options.offset = options.offset || defaults.offset;
|
||||
options.blendMode = options.blendMode || defaults.blendMode;
|
||||
|
||||
var output;
|
||||
|
||||
@@ -15,9 +16,6 @@ module.exports = function Dynamic(options, UI, util) {
|
||||
|
||||
var step = this;
|
||||
|
||||
// convert to runnable code:
|
||||
if (typeof options.func === 'string') eval('options.func = ' + options.func);
|
||||
|
||||
var getPixels = require('get-pixels');
|
||||
|
||||
// convert offset as string to int
|
||||
@@ -32,19 +30,79 @@ module.exports = function Dynamic(options, UI, util) {
|
||||
callback();
|
||||
}
|
||||
|
||||
// see http://docs.gimp.org/en/gimp-concepts-layer-modes.html for other blend modes
|
||||
|
||||
const multiply_mode = function (i, m) {
|
||||
return ~~( (i * m) / 255 );
|
||||
};
|
||||
const divide_mode = function (i, m) {
|
||||
return ~~( (256 * i) / (m + 1) );
|
||||
};
|
||||
|
||||
const overlay_mode = function (i, m) {
|
||||
return ~~( (i / 255) * (i + ((2 * m) / 255) * (255 - i)) );
|
||||
};
|
||||
|
||||
const screen_mode = function (i, m) {
|
||||
return ~~( 255 - ((255 - m) * (255 - i)) / 255 );
|
||||
};
|
||||
|
||||
const sof_light_mode = function (i, m) {
|
||||
var Rs = screen_mode(i, m);
|
||||
return ~~( ((((255 - i) * m) + Rs) * i) / 255 );
|
||||
};
|
||||
|
||||
const color_dodge = function (i, m) {
|
||||
return ~~( (256 * i) / (255 - m + 1) );
|
||||
};
|
||||
|
||||
const burn_mode = function (i, m) {
|
||||
return ~~( 255 - (256 * (255 - i)) / (m + 1));
|
||||
};
|
||||
|
||||
const grain_extract_mode = function (i, m) {
|
||||
return ~~( i - m + 128 );
|
||||
};
|
||||
|
||||
const grain_merge_mode = function (i, m) {
|
||||
return ~~( i + m - 128 );
|
||||
};
|
||||
|
||||
|
||||
getPixels(priorStep.output.src, function(err, pixels) {
|
||||
options.firstImagePixels = pixels;
|
||||
|
||||
// Convert to runnable code.
|
||||
if (typeof options.func === 'string') eval('options.func = ' + options.func);
|
||||
|
||||
function changePixel(r2, g2, b2, a2, x, y) {
|
||||
// blend!
|
||||
let p = options.firstImagePixels;
|
||||
return options.func(
|
||||
r2, g2, b2, a2,
|
||||
p.get(x, y, 0),
|
||||
p.get(x, y, 1),
|
||||
p.get(x, y, 2),
|
||||
p.get(x, y, 3)
|
||||
);
|
||||
let r1 = p.get(x, y, 0),
|
||||
g1 = p.get(x, y, 1),
|
||||
b1 = p.get(x, y, 2),
|
||||
a1 = p.get(x, y, 3);
|
||||
|
||||
const blends = {
|
||||
'Color Dodge': () => [color_dodge(r2, r1), color_dodge(g2, g1), color_dodge(b2, b1), 255],
|
||||
'Multiply': () => [multiply_mode(r2, r1), multiply_mode(g2, g1), multiply_mode(b2, b1), multiply_mode(a2, a1)],
|
||||
'Divide': () => [divide_mode(r2, r1), divide_mode(g2, g1), divide_mode(b2, b1), 255],
|
||||
'Overlay': () => [overlay_mode(r2, r1), overlay_mode(g2, g1), overlay_mode(b2, b1), 255],
|
||||
'Screen': () => [screen_mode(r2, r1), screen_mode(g2, g1), screen_mode(b2, b1), 255],
|
||||
'Soft Light': () => [sof_light_mode(r2, r1), sof_light_mode(g2, g1), sof_light_mode(b2, b1), 255],
|
||||
'Color Burn': () => [burn_mode(r2, r1), burn_mode(g2, g1), burn_mode(b2, b1), 255],
|
||||
'Grain Extract': () => [grain_extract_mode(r2, r1), grain_extract_mode(g2, g1), grain_extract_mode(b2, b1), 255],
|
||||
'Grain Merge': () => [grain_merge_mode(r2, r1), grain_merge_mode(g2, g1), grain_merge_mode(b2, b1), 255]
|
||||
};
|
||||
|
||||
if(options.blendMode == 'custom')
|
||||
return options.func(
|
||||
r2, g2, b2, a2, r1, g1, b1, a1
|
||||
);
|
||||
else {
|
||||
return blends[options.blendMode]();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype, wasmSuccess) {
|
||||
|
||||
@@ -1,17 +1,34 @@
|
||||
{
|
||||
"name": "blend",
|
||||
"description": "Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!",
|
||||
"description": "Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2.",
|
||||
"inputs": {
|
||||
"offset": {
|
||||
"type": "integer",
|
||||
"desc": "Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.",
|
||||
"default": -2
|
||||
},
|
||||
"blendMode": {
|
||||
"type": "select",
|
||||
"desc": "Name of the Blend Mode to use",
|
||||
"default": "custom",
|
||||
"values": [
|
||||
"custom",
|
||||
"Multiply",
|
||||
"Divide",
|
||||
"Overlay",
|
||||
"Screen",
|
||||
"Soft Light",
|
||||
"Color Burn",
|
||||
"Color Dodge",
|
||||
"Grain Extract",
|
||||
"Grain Merge"
|
||||
]
|
||||
},
|
||||
"blend": {
|
||||
"type": "string",
|
||||
"desc": "Function to use to blend the two images.",
|
||||
"default": "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"
|
||||
"default": "function(r1, g1, b1, a1, r2, g2, b2, a2, x, y) { return [ r2, g2, b2, a2 ] }"
|
||||
}
|
||||
},
|
||||
"docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#blend-module"
|
||||
"docs-link": "https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#blend-module"
|
||||
}
|
||||
|
||||
@@ -59,12 +59,6 @@ module.exports = function CropModuleUi(step, ui) {
|
||||
];
|
||||
}
|
||||
|
||||
function remove() {
|
||||
$(imgEl()).imgAreaSelect({
|
||||
remove: true
|
||||
});
|
||||
}
|
||||
|
||||
function hide() {
|
||||
// then hide the draggable UI
|
||||
$(imgEl()).imgAreaSelect({
|
||||
@@ -92,7 +86,6 @@ module.exports = function CropModuleUi(step, ui) {
|
||||
|
||||
return {
|
||||
setup: setup,
|
||||
remove: remove,
|
||||
hide: hide
|
||||
};
|
||||
};
|
||||
|
||||
@@ -10,8 +10,8 @@ module.exports = exports = function(pixels, options){
|
||||
iw = pixels.shape[0],
|
||||
ih = pixels.shape[1],
|
||||
thickness = Number(options.thickness) || defaults.thickness,
|
||||
ex = Number(options.endX) - thickness || iw - 1,
|
||||
ey = Number(options.endY) - thickness || ih - 1,
|
||||
ex = options.endX = Number(options.endX || defaults.endX) - thickness || iw - 1,
|
||||
ey = options.endY = Number(options.endY || defaults.endY) - thickness || ih - 1,
|
||||
color = options.color || defaults.color;
|
||||
|
||||
color = color.substring(color.indexOf('(') + 1, color.length - 1); // Extract only the values from rgba(_,_,_,_)
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
"endX":{
|
||||
"type": "integer",
|
||||
"desc": "last x position of the rectangle",
|
||||
"default": "width"
|
||||
"default": 10
|
||||
},
|
||||
|
||||
"endY":{
|
||||
"type": "integer",
|
||||
"desc": "last y position of the rectangle",
|
||||
"default": "height"
|
||||
"default": 10
|
||||
},
|
||||
|
||||
"thickness":{
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = function Channel(options, UI) {
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
options.gradient = options.gradient || defaults.gradient;
|
||||
options.gradient = JSON.parse(options.gradient);
|
||||
options.gradient = String(JSON.parse(options.gradient));
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = exports = function(pixels, options) {
|
||||
minFactor = (1 - tolerance / 100);
|
||||
fillColor = fillColor.substring(fillColor.indexOf('(') + 1, fillColor.length - 1); // extract only the values from rgba(_,_,_,_)
|
||||
fillColor = fillColor.split(',');
|
||||
|
||||
fillColor[3] = fillColor[3] * 255;
|
||||
function isSimilar(currx, curry) {
|
||||
return (pixels.get(currx, curry, 0) >= r * minFactor && pixels.get(currx, curry, 0) <= r * maxFactor &&
|
||||
pixels.get(currx, curry, 1) >= g * minFactor && pixels.get(currx, curry, 1) <= g * maxFactor &&
|
||||
|
||||
@@ -7,10 +7,17 @@ module.exports = function TextOverlay(options, UI) {
|
||||
|
||||
var step = this;
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
function extraManipulation(pixels, setRenderState, generateOutput) {
|
||||
//if (options.step.inBrowser)
|
||||
pixels = require('./TextOverlay')(pixels, options);
|
||||
return pixels;
|
||||
const getDataUri = require('../../util/getDataUri');
|
||||
getDataUri(pixels, input.format).then(dataUri => {
|
||||
setRenderState(false);
|
||||
pixels = require('./TextOverlay')(pixels, options, dataUri, () => {
|
||||
setRenderState(true);
|
||||
generateOutput();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype, wasmSuccess) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = exports = function(pixels, options){
|
||||
const getPixels = require('get-pixels'),
|
||||
pixelSetter = require('../../util/pixelSetter.js');
|
||||
module.exports = exports = function(pixels, options, url1, cb){
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
|
||||
options.text = options.text || defaults.text;
|
||||
@@ -12,14 +14,42 @@ module.exports = exports = function(pixels, options){
|
||||
canvas.width = pixels.shape[0]; //img.width();
|
||||
canvas.height = pixels.shape[1]; //img.height();
|
||||
var ctx = canvas.getContext('2d');
|
||||
var image = new Image;
|
||||
image.src = url1;
|
||||
image.onload = function(){
|
||||
|
||||
ctx.drawImage(image, 0, 0);
|
||||
ctx.fillStyle = options.color;
|
||||
ctx.font = options.size + 'px ' + options.font;
|
||||
ctx.fillText(options.text, options.x, options.y);
|
||||
|
||||
ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.shape[0], pixels.shape[1]), 0, 0);
|
||||
getPixels(canvas.toDataURL(), function (err, qrPixels) {
|
||||
if (err) {
|
||||
console.log('get-pixels error: ', err);
|
||||
}
|
||||
|
||||
ctx.fillStyle = options.color;
|
||||
ctx.font = options.size + 'px ' + options.font;
|
||||
ctx.fillText(options.text, options.x, options.y);
|
||||
|
||||
|
||||
for (let x = 0; x < pixels.shape[0]; x++) {
|
||||
for (let y = 0; y < pixels.shape[1]; y++) {
|
||||
pixelSetter(
|
||||
x,
|
||||
y,
|
||||
[
|
||||
qrPixels.get(x, y, 0),
|
||||
qrPixels.get(x, y, 1),
|
||||
qrPixels.get(x, y, 2),
|
||||
qrPixels.get(x, y, 3)
|
||||
],
|
||||
pixels
|
||||
);
|
||||
}
|
||||
}
|
||||
if (cb) cb();
|
||||
});
|
||||
};
|
||||
|
||||
var myImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
pixels.data = new Uint8Array(myImageData.data);
|
||||
return pixels;
|
||||
|
||||
|
||||
|
||||
};
|
||||
@@ -4,7 +4,8 @@ const pixelSetter = require('../../util/pixelSetter.js'),
|
||||
ndarray = require('ndarray'),
|
||||
gifshot = require('gifshot'),
|
||||
fs = require('fs'),
|
||||
path = require('path');
|
||||
path = require('path'),
|
||||
getDataUri = require('../../util/getDataUri');
|
||||
/*
|
||||
* General purpose per-pixel manipulation
|
||||
* accepting a changePixel() method to remix a pixel's channels
|
||||
@@ -45,36 +46,7 @@ module.exports = function PixelManipulation(image, options) {
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* @description Returns the DataURI of an image from its pixels
|
||||
* @param {"ndarray"} pix pixels ndarray of pixels of the image.
|
||||
* @param {String} format Format/MimeType of the image input.
|
||||
* @returns {Promise} Promise with DataURI as parameter in the callback.
|
||||
*/
|
||||
const getDataUri = (pix, format) => {
|
||||
return new Promise(resolve => {
|
||||
let chunks = [],
|
||||
totalLength = 0;
|
||||
|
||||
let r = savePixels(pix, format, {
|
||||
quality: 100
|
||||
});
|
||||
|
||||
r.on('data', function (chunk) {
|
||||
totalLength += chunk.length;
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
r.on('end', function () {
|
||||
let data = Buffer.concat(chunks, totalLength).toString('base64');
|
||||
let datauri = 'data:image/' + format + ';base64,' + data;
|
||||
|
||||
resolve(datauri);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
getPixels(image.src, function (err, pixels) {
|
||||
if (err) {
|
||||
console.log('get-pixels error: ', err);
|
||||
|
||||
31
src/util/getDataUri.js
Normal file
31
src/util/getDataUri.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const savePixels = require('save-pixels');
|
||||
|
||||
/**
|
||||
* @description Returns the DataURI of an image from its pixels
|
||||
* @param {"ndarray"} pix pixels ndarray of pixels of the image.
|
||||
* @param {String} format Format/MimeType of the image input.
|
||||
* @returns {Promise} Promise with DataURI as parameter in the callback.
|
||||
*/
|
||||
|
||||
module.exports = getDataUri = (pix, format) => {
|
||||
return new Promise(resolve => {
|
||||
let chunks = [],
|
||||
totalLength = 0;
|
||||
|
||||
let r = savePixels(pix, format, {
|
||||
quality: 100
|
||||
});
|
||||
|
||||
r.on('data', function(chunk) {
|
||||
totalLength += chunk.length;
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
r.on('end', function() {
|
||||
let data = Buffer.concat(chunks, totalLength).toString('base64');
|
||||
let datauri = 'data:image/' + format + ';base64,' + data;
|
||||
|
||||
resolve(datauri);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
const getPixels = require('get-pixels');
|
||||
module.exports = function getImageDimensions(img, cb) {
|
||||
let dimensions;
|
||||
let isGIF;
|
||||
getPixels(img, function(err, pixels) {
|
||||
if (pixels.shape.length === 4) {
|
||||
const [frames, width, height] = pixels.shape;
|
||||
@@ -10,8 +9,6 @@ module.exports = function getImageDimensions(img, cb) {
|
||||
width,
|
||||
height
|
||||
};
|
||||
|
||||
isGIF = true;
|
||||
}
|
||||
else {
|
||||
const [width, height] = pixels.shape;
|
||||
@@ -19,11 +16,9 @@ module.exports = function getImageDimensions(img, cb) {
|
||||
width,
|
||||
height
|
||||
};
|
||||
|
||||
isGIF = false;
|
||||
}
|
||||
|
||||
if (cb) cb(dimensions, isGIF);
|
||||
if (cb) cb(dimensions);
|
||||
});
|
||||
};
|
||||
|
||||
7
src/util/isGif.js
Normal file
7
src/util/isGif.js
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = function(url){
|
||||
if(url.match){
|
||||
const toMatch = url.match(/data:image\/(.*);/) || 'png';
|
||||
return toMatch[1] === 'gif';
|
||||
}else
|
||||
return false;
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,12 @@
|
||||
const benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==',
|
||||
moduleTest = require('../templates/module-test');
|
||||
const benchmark =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==',
|
||||
moduleTest = require('../templates/module-test'),
|
||||
optionsTest = require('../templates/options-test'),
|
||||
benchmark1 =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==',
|
||||
benchmark2 =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==';
|
||||
|
||||
moduleTest('blur', {blur: 3.25}, benchmark);
|
||||
moduleTest('blur', { blur: 3.25 }, benchmark);
|
||||
|
||||
optionsTest('blur', [{ blur: 2 }, { blur: 0.45 }], [benchmark1, benchmark2]);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
const benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAd2KE6QAAAAHdElNRQfjAgULAir0wiRrAAAADUlEQVQY02NgGAXIAAABEAAB7JfjegAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wMi0wNVQxMTowMjo0MiswMjowMCdP+X4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDItMDVUMTE6MDI6NDIrMDI6MDBWEkHCAAAAAElFTkSuQmCC',
|
||||
testModule = require('../templates/module-test');
|
||||
benchmark1 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==',
|
||||
benchmark2 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAAqSURBVKXBAQEAAAiAIHNf/+/UCGEWjkAiiSSSSCKJJJJIIokkkkgiiSR6gcMBa2MNA5YAAAAASUVORK5CYII=',
|
||||
testModule = require('../templates/module-test'),
|
||||
optionsTest = require('../templates/options-test');
|
||||
|
||||
testModule('brightness', {brightness: 1}, benchmark);
|
||||
testModule('brightness', {brightness: 1}, benchmark);
|
||||
|
||||
optionsTest('brightness', [{brightness: 175}, {brightness: 30}], [benchmark1, benchmark2]);
|
||||
@@ -1,4 +1,9 @@
|
||||
const benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==',
|
||||
testModule = require('../templates/module-test');
|
||||
testModule = require('../templates/module-test'),
|
||||
optionsTest = require('../templates/options-test'),
|
||||
benchmark1 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAMAzDIF7/nncRgYcTTDTRRBNNNNFEE0000UQTTTTRRB9NQAEfe+dsMAAAAABJRU5ErkJggg==',
|
||||
benchmark2 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==';
|
||||
|
||||
testModule('channel', {channel: 'red'}, benchmark);
|
||||
|
||||
optionsTest('channel', [{channel: 'green'}, {channel: 'red'}], [benchmark1, benchmark2]);
|
||||
@@ -2,6 +2,10 @@ const testModule = require('../templates/module-test'),
|
||||
options = {
|
||||
temperature: 20000
|
||||
},
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPN242uEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1AkwGaEGLV7wAAAABJRU5ErkJggg==';
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPN242uEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1AkwGaEGLV7wAAAABJRU5ErkJggg==',
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==',
|
||||
optionsTest = require('../templates/options-test');
|
||||
|
||||
testModule('color-temperature', options, benchmark);
|
||||
testModule('color-temperature', options, benchmark);
|
||||
|
||||
optionsTest('color-temperature', [options, {temperature: 60}], [benchmark, _benchmark]);
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,15 @@
|
||||
const benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAArSURBVKXBAQEAAAiAIPP/ti7VCGFm7wgkkkgiiSSSSCKJJJJIIokkkkiiB53vAu3tsMmFAAAAAElFTkSuQmCC',
|
||||
const benchmark =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAArSURBVKXBAQEAAAiAIPP/ti7VCGFm7wgkkkgiiSSSSCKJJJJIIokkkkiiB53vAu3tsMmFAAAAAElFTkSuQmCC',
|
||||
testModule = require('../templates/module-test');
|
||||
|
||||
testModule('colormap', {colormap: 'blutoredjet'}, benchmark);
|
||||
testModule('colormap', { colormap: 'blutoredjet' }, benchmark);
|
||||
|
||||
const optionsTestModule = require('../templates/options-test');
|
||||
|
||||
const benchmarks = [
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAAtSURBVKXBAQEAIAyAME4I81nUbD4E25z7PoFEEkkkkUQSSSSRRBJJJJFEEkm0Ka4CUk/bqgMAAAAASUVORK5CYII=',
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAArSURBVKXBAQEAMAyDMI7G+reyiyB5245AIokkkkgiiSSSSCKJJJJIIokk+ktEAhuHny9oAAAAAElFTkSuQmCC'
|
||||
],
|
||||
options = [{ colormap: 'default' }, { colormap: 'greyscale' }];
|
||||
|
||||
optionsTestModule('colormap', options, benchmarks);
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
const benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAHklEQVQ4T2Pc4u39n4ECwDhqAMNoGDCMhgHDsAgDALGCJKF4bsMPAAAAAElFTkSuQmCC',
|
||||
testModule = require('../templates/module-test');
|
||||
const benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==',
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==',
|
||||
testModule = require('../templates/module-test'),
|
||||
optionsChange = require('../templates/options-test'),
|
||||
option = {contrast: 40},
|
||||
_option = {contrast: 84};
|
||||
|
||||
testModule('contrast', {contrast: -40}, benchmark);
|
||||
testModule('contrast', option, benchmark);
|
||||
|
||||
optionsChange('contrast', [option, _option], [benchmark, _benchmark]);
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,8 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAB/SURBVKXBAQHAIAAEoXP9OzM/g9BlKlOZylSmMpWpzKn04OtCgwYNGjRo0KBT6cHXhQYNGjRo0KBBp9KDrwsNGjRo0KBBg06lB18XGjRo0KBBgwadSg++LjRo0KBBgwYNOpUefF1o0KBBgwYNGnQqPfi60KBBgwYNGjToVHrwA6E21z8iJpDFAAAAAElFTkSuQmCC';
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAADSSURBVJ3BQWoEQQDEMLv//2dnCrYhDJtLJIH4p4rDo2IqpmIqpmIqpmJUBOKLCpW3CpWpODwqpuJSqZiKS2UqVA4PlVGpmIpLpWIqRmXsoVKh8lah8luFyhyVUZmKqRiVqbhUKuZUTMWojErFpVJxqcxRGZWKqRiVqRiViqkYe6i8VahUqPzlqFRMxaUyKlMxFVMxp0JlVCqmYipGZVQqVEYgHhUq31SoVKhcFYcPlYqpmIpRGZWKS+VUXCqjMioVUzEqFddRqZiKqbhURuVSqZgfDhnK7U8O3MsAAAAASUVORK5CYII=',
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAB/SURBVKXBAQHAIAAEoXP9OzM/g9BlKlOZylSmMpWpzKn04OtCgwYNGjRo0KBT6cHXhQYNGjRo0KBBp9KDrwsNGjRo0KBBg06lB18XGjRo0KBBgwadSg++LjRo0KBBgwYNOpUefF1o0KBBgwYNGnQqPfi60KBBgwYNGjToVHrwA6E21z8iJpDFAAAAAElFTkSuQmCC',
|
||||
option = {dither: 'floydsteinberg'},
|
||||
_options = {dither: 'bayer'};
|
||||
require('../templates/options-test')('dither', [option, _options], [benchmark, _benchmark]);
|
||||
|
||||
testModule('dither', {dither: 'bayer'}, benchmark);
|
||||
testModule('dither', {dither: 'floydsteinberg'}, benchmark);
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,14 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAAAklEQVR4AewaftIAAApfSURBVO3BK3Nbh9qA0We/oxnvICVIZZGRUuQUnRRJQU2RoMPOFDVFpWX1T2hR87GWNSxGqZFlVqP0oNTIEqtQLGQH7S8epSPLlzjOxfa79axVVK8hSQkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQSSlEQgSUkEkpREIElJBJKURCBJSQ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Wfh5Ky1svfOc99//30uLi7y8PCQ37LWynN77/wVa63AX9VwktZa+dz9/X3+iPfv3wf+CQ0na62Vz+2983vevn2bv2rvHfirGk7aWiuf23sHXqKzcPJ+/vnnfPHFF3lu751P1lr51d478E86Cyfvyy+/zN47v2XvHXgpGo7O3jt/1vn5eY7B3jscrwY+enp6Crx0DfxirZXz8/PAS3UWeObp6Slrrfxq753nzs/P8/j4GPgnnIWjdHl5mbu7u/xda61McXl5GY5bw1G6vb3Nqbm9vQ3HreFo7b1zKvbe4fg1HLXD4ZBjdzgcwmloOGrX19c5HA45VofDIdfX1+E0NBy96+vr7L1zbPbeub6+Dqej4WTsvXN5eZm/Y++dv+unn37K33F5eZm9dzg9a38UTtpaK7/n9evXub+/z3/S+fl5np6e8nv23oFP1v4oAAM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEM0AEP8D7PdBnMb2pAsAAAAAElFTkSuQmCC',
|
||||
image = require('../images/IS-QR'),
|
||||
options = {
|
||||
exposure: 3
|
||||
},
|
||||
_options = {
|
||||
exposure: 4
|
||||
};
|
||||
|
||||
require('../templates/options-test')('exposure', [options, _options], [benchmark, _benchmark], image);
|
||||
|
||||
testModule('exposure', options, benchmark, image);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,4 +1,9 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAMAzDIF7/nncRgYcTTDTRRBNNNNFEE0000UQTTTTRRB9NQAEfe+dsMAAAAABJRU5ErkJggg==';
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAMAzDIF7/nncRgYcTTDTRRBNNNNFEE0000UQTTTTRRB9NQAEfe+dsMAAAAABJRU5ErkJggg==',
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAMAzDIF7/nncRgYcTTDTRRBNNNNFEE0000UQTTTTRRB9NQAEfe+dsMAAAAABJRU5ErkJggg==',
|
||||
option = {x: 1},
|
||||
_options = {x: 1, y: 1};
|
||||
|
||||
require('../templates/options-test')('grid-overlay', [option, _options], [benchmark, _benchmark]);
|
||||
|
||||
testModule('grid-overlay', {x: 1}, benchmark);
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,9 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==';
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==',
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5mqEMAtHIJFEEkkkkUQSSSSRRBJJJJFEEj1UXgIdx5M8pQAAAABJRU5ErkJggg==',
|
||||
option = {method: 'Median Filtering'},
|
||||
_option = {method: 'Mean Filtering'};
|
||||
|
||||
testModule('noise-reduction', {method: 'Median Filtering'}, benchmark);
|
||||
require('../templates/options-test')('noise-reduction', [option, _option], [benchmark, _benchmark]);
|
||||
|
||||
testModule('noise-reduction', option, benchmark);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,7 +1,13 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAAtSURBVKXBAQEAMAiAME6H9y9nDw3B9v7MEkgkkUQSSSSRRBJJJJFEEkkkkUQH2vAC/LDhuwsAAAAASUVORK5CYII=',
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAAsSURBVKXBAQEAMAiAME43m7+XhmB7f2YJJJJIIokkkkgiiSSSSCKJJJJIogOYTgJtR8dNuwAAAABJRU5ErkJggg==',
|
||||
_options = {
|
||||
saturation: 0.5
|
||||
},
|
||||
options = {
|
||||
saturation: 1.2
|
||||
};
|
||||
|
||||
require('../templates/options-test')('saturation', [options, _options], [benchmark, _benchmark]);
|
||||
|
||||
testModule('saturation', options, benchmark);
|
||||
@@ -1,4 +1,9 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
_benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAMAzDIF7/nncRgYcTTDTRRBNNNNFEE0000UQTTTTRRB9NQAEfe+dsMAAAAABJRU5ErkJggg==',
|
||||
option = {threshold: 'Automatic Thresholding'},
|
||||
_option = {threshold: 'Manual Thresholding'},
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiAIPP/5+qDMPsIJJJIIokkkkgiiSSSSCKJJJJIogNrygQcXEYsHQAAAABJRU5ErkJggg==';
|
||||
|
||||
testModule('threshold', {threshold: 'Automatic Thresholding'}, benchmark);
|
||||
testModule('threshold', option, benchmark);
|
||||
|
||||
require('../templates/options-test')('threshold', [option, _option], [benchmark, _benchmark]);
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,11 @@
|
||||
const testModule = require('../templates/module-test'),
|
||||
options = {red: 240, green: 240, blue: 240},
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==';
|
||||
options = {'red': '240', 'green': '240', 'blue': '240'},
|
||||
_options = {'red': '255', 'green': '255', 'blue': '255'},
|
||||
_options2 = {'red': '12', 'green': '12', 'blue': '12'},
|
||||
benchmark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==',
|
||||
benchmark1 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==',
|
||||
benchmark2 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAklEQVR4AewaftIAAAApSURBVKXBAQEAAAiDMKR/5xuC7QYjkEgiiSSSSCKJJJJIIokkkkgiiR5YbQIegx78CAAAAABJRU5ErkJggg==';
|
||||
|
||||
require('../templates/options-test')('white-balance', [_options, _options2], [benchmark1, benchmark2]);
|
||||
|
||||
testModule('white-balance', options, benchmark);
|
||||
@@ -192,7 +192,7 @@ test('getStep(offset) returns the step at offset distance relative to current st
|
||||
});
|
||||
|
||||
test('toCliString() returns the CLI command for the sequence', function(t) {
|
||||
t.deepEqual(sequencer.toCliString(), 'sequencer -i [PATH] -s "channel channel channel channel invert brightness average brightness invert blend" -d \'{"channel":"green","brightness":"1","offset":-2}\'', 'works correctly');
|
||||
t.deepEqual(sequencer.toCliString(), 'sequencer -i [PATH] -s "channel channel channel channel invert brightness average brightness invert blend" -d \'{"channel":"green","brightness":"1","offset":-2,"blendMode":"custom"}\'', 'works correctly');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
64
test/core/templates/options-test.js
Normal file
64
test/core/templates/options-test.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const test = require('tape'),
|
||||
base64Img = require('base64-img'),
|
||||
looksSame = require('looks-same');
|
||||
|
||||
const ImageSequencer = require('../../../src/ImageSequencer');
|
||||
|
||||
const red =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABlBMVEX+AAD///+KQee0AAAAAWJLR0QB/wIt3gAAAAd0SU1FB+EGHRIVAvrm6EMAAAAMSURBVAjXY2AgDQAAADAAAceqhY4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDYtMjlUMTg6MjE6MDIrMDI6MDDGD83DAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA2LTI5VDE4OjIxOjAyKzAyOjAwt1J1fwAAAABJRU5ErkJggg==';
|
||||
target = 'test_outputs';
|
||||
|
||||
/**
|
||||
* @method OptionsChangeTest.
|
||||
* @description a common test for modules.
|
||||
* @param {String} moduleName name of the module.
|
||||
* @param {'Object'} [options] array of options.
|
||||
* @param {String} [benchmark] dataURI of the benchmark images, a image for each option.
|
||||
* @param {String} [input='red_image'] optional input image. Default is a red image.
|
||||
*/
|
||||
module.exports = (moduleName, options, benchmark, input) => {
|
||||
let sequencer = ImageSequencer({ ui: false });
|
||||
|
||||
test(`${moduleName} module works correctly with different options`, t => {
|
||||
// Load the input image.
|
||||
sequencer.loadImages(input || red);
|
||||
// Add the step.
|
||||
sequencer.addSteps(moduleName, options[0]);
|
||||
// Run the ImageSequencer with initial option.
|
||||
sequencer.run({ mode: 'test' }, () => {
|
||||
let result = sequencer.steps[1].output.src;
|
||||
|
||||
base64Img.imgSync(result, target, 'result');
|
||||
base64Img.imgSync(benchmark[0], target, 'benchmark');
|
||||
|
||||
result = './test_outputs/result.png';
|
||||
benchmark[0] = './test_outputs/benchmark.png';
|
||||
// Check to see if first option is correctly loaded.
|
||||
looksSame(result, benchmark[0], function(err, res) {
|
||||
if (err) console.log(err);
|
||||
|
||||
t.equal(res.equal, true, `${moduleName} module works correctly with initial option ${options[0][moduleName]}`);
|
||||
});
|
||||
// Change the option of the given module.
|
||||
sequencer.steps[1].setOptions(options[1]);
|
||||
// Run the ImageSequencer witch changed option.
|
||||
sequencer.run({ mode: 'test' }, () => {
|
||||
let newResult = sequencer.steps[1].output.src;
|
||||
|
||||
base64Img.imgSync(newResult, target, 'newResult');
|
||||
base64Img.imgSync(benchmark[1], target, 'benchmark');
|
||||
|
||||
newResult = './test_outputs/newResult.png';
|
||||
benchmark[1] = './test_outputs/benchmark.png';
|
||||
// Check to see if change in option changed the image correctly.
|
||||
looksSame(newResult, benchmark[1], function(err, res) {
|
||||
if (err) console.log(err);
|
||||
|
||||
t.equal(res.equal, true, `${moduleName} module works correctly when the option is changed to ${options[1][moduleName]}`);
|
||||
sequencer = null;
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
46
test/ui-2/test/cropui.test.js
Normal file
46
test/ui-2/test/cropui.test.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const timeout = 300000 ;
|
||||
const fs = require('fs');
|
||||
beforeAll(async () => {
|
||||
path = fs.realpathSync('file://../examples/index.html');
|
||||
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
|
||||
await page.setViewport({ width: 1500, height: 700});
|
||||
});
|
||||
describe('Crop UI', ()=>{
|
||||
test('Crop UI', async()=>{
|
||||
// Wait for the load step to get loaded.
|
||||
await page.waitForSelector('.step');
|
||||
const Length = await page.evaluate(() => document.querySelectorAll('.step').length);
|
||||
// Click on the Crop step from radio-group.
|
||||
await page.click('[data-value=\'crop\']');
|
||||
const LengthChanged = await page.evaluate(() => document.querySelectorAll('.step').length);
|
||||
const src1 = await page.evaluate(() => document.querySelectorAll('.step img')[1].src);
|
||||
const example = await page.$$('img.step-thumbnail');
|
||||
/**
|
||||
* Drawing a bounding box around the image to be cropped.
|
||||
* box.x returns x position of mouse pointer.
|
||||
* box.y returns y position of mouse pointer.
|
||||
**/
|
||||
const box = await example[1].boundingBox();
|
||||
// Moving mouse pointer inside the the image.
|
||||
await page.mouse.move(box.x, box.y);
|
||||
await page.mouse.move(box.x + 50, box.y);
|
||||
await page.mouse.move(box.x + 50, box.y + 50);
|
||||
// Mouse.down() dispatches a mousedown event.
|
||||
await page.mouse.down();
|
||||
// Selecting area to be cropped.
|
||||
await page.mouse.move(box.x + 50, box.y + 200);
|
||||
await page.mouse.move(box.x + 200, box.y + 200);
|
||||
// Mouse.up() dispatches a mouseup event.
|
||||
await page.mouse.up();
|
||||
// Removing the crop step from the sequence.
|
||||
await page.click('.remove.btn-default');
|
||||
const Lengthremoved = await page.evaluate(() => document.querySelectorAll('.step').length);
|
||||
// Checking if we can select the crop step again or not.
|
||||
await page.click('[data-value=\'crop\']');
|
||||
const LengthReadded = await page.evaluate(() => document.querySelectorAll('.step').length);
|
||||
expect(Length).toBe(1);
|
||||
expect(LengthChanged).toBe(2);
|
||||
expect(Lengthremoved).toBe(1);
|
||||
expect(LengthReadded).toBe(2);
|
||||
}, timeout);
|
||||
});
|
||||
16
yarn.lock
16
yarn.lock
@@ -3944,10 +3944,10 @@ gl-wiretap@^0.6.2:
|
||||
resolved "https://registry.yarnpkg.com/gl-wiretap/-/gl-wiretap-0.6.2.tgz#e4aa19622831088fbaa7e5a18d01768f7a3fb07c"
|
||||
integrity sha512-fxy1XGiPkfzK+T3XKDbY7yaqMBmozCGvAFyTwaZA3imeZH83w7Hr3r3bYlMRWIyzMI/lDUvUMM/92LE2OwqFyQ==
|
||||
|
||||
gl@^4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/gl/-/gl-4.4.0.tgz#3d448769a9222ba809da4db80dd1f3c4b85498a0"
|
||||
integrity sha512-4FIq5tqiltTsadrLh6DGY4R9+aQwj25OM2WlXEv81N6YN1q1C0qR7ct0SKp1uUJdnBqbKhUJP3zQ1td40AVeJg==
|
||||
gl@^4.4.1:
|
||||
version "4.4.1"
|
||||
resolved "https://registry.yarnpkg.com/gl/-/gl-4.4.1.tgz#515f3d4f3120ef5001fe15ae1f0fea1e04d69e2c"
|
||||
integrity sha512-2ZG8/qUAQ6WRgPzflsiLbx1KBgrKra0T0GJeG6xyxzNYvUOoeFFPIJJZ/e9X089yag+4NcrzD0ql7PfbJCuuqQ==
|
||||
dependencies:
|
||||
bindings "^1.5.0"
|
||||
bit-twiddle "^1.0.2"
|
||||
@@ -4148,12 +4148,12 @@ gpu-mock.js@^1.1.1:
|
||||
integrity sha512-BmoRk9nbMaxkrwzTJp4M0iuwIbzNEXt6tlBZ5+ZYzaGH9VWu5Nhn1Q1CBusCam3d8u3FfVEFf3Ueo8DocUCbUw==
|
||||
|
||||
gpu.js@^2.3.1:
|
||||
version "2.4.8"
|
||||
resolved "https://registry.yarnpkg.com/gpu.js/-/gpu.js-2.4.8.tgz#59e980edfdb622b8e5f85ace012214b7d0525911"
|
||||
integrity sha512-V4CAZIR+kV6enLVPGoeZdb4lK4FGGuolDDYNBMAlNzrfDN7OJjl2V9we6bKDTKhV/gwsYmivs0x22qo/Q0zHzA==
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/gpu.js/-/gpu.js-2.6.2.tgz#e5605a7989761ed86c24c516d665898741b70814"
|
||||
integrity sha512-Ond7t6xGUn4bUC/vzI2D8VgBIharso7LIr66ZvLy01JOUkGLQ2DgSUXZ9gix1iSzZ9e6/EQWcBkHDNehUePbFA==
|
||||
dependencies:
|
||||
acorn "^7.1.0"
|
||||
gl "^4.4.0"
|
||||
gl "^4.4.1"
|
||||
gl-wiretap "^0.6.2"
|
||||
gpu-mock.js "^1.1.1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user