mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 04:10:04 +01:00
Added Eslint and husky (#1062)
This commit is contained in:
@@ -3,70 +3,70 @@
|
||||
*/
|
||||
module.exports = function Resize(options, UI) {
|
||||
|
||||
var output;
|
||||
var output;
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
options.resize = options.resize || defaults.resize;
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
options.resize = options.resize || defaults.resize;
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
var step = this;
|
||||
var step = this;
|
||||
|
||||
var imagejs = require('imagejs');
|
||||
var imagejs = require('imagejs');
|
||||
|
||||
function changePixel(r, g, b, a) {
|
||||
return [r, g, b, a]
|
||||
}
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
// value above 100% scales up, and below 100% scales down
|
||||
var resize_value = parseInt(options.resize.slice(0, -1));
|
||||
|
||||
var new_width,
|
||||
new_height;
|
||||
|
||||
new_width = Math.round(pixels.shape[0] * (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]});
|
||||
bitmap._data.data = pixels.data;
|
||||
|
||||
|
||||
var resized = bitmap.resize({
|
||||
width: new_width, height: new_height,
|
||||
algorithm: "bicubicInterpolation"
|
||||
});
|
||||
|
||||
pixels.data = resized._data.data;
|
||||
pixels.shape = [new_width,new_height,4];
|
||||
pixels.stride[1] = 4 * new_width;
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype) {
|
||||
// This output is accesible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
changePixel: changePixel,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback
|
||||
});
|
||||
function changePixel(r, g, b, a) {
|
||||
return [r, g, b, a];
|
||||
}
|
||||
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
function extraManipulation(pixels) {
|
||||
// value above 100% scales up, and below 100% scales down
|
||||
var resize_value = parseInt(options.resize.slice(0, -1));
|
||||
|
||||
var new_width,
|
||||
new_height;
|
||||
|
||||
new_width = Math.round(pixels.shape[0] * (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]});
|
||||
bitmap._data.data = pixels.data;
|
||||
|
||||
|
||||
var resized = bitmap.resize({
|
||||
width: new_width, height: new_height,
|
||||
algorithm: 'bicubicInterpolation'
|
||||
});
|
||||
|
||||
pixels.data = resized._data.data;
|
||||
pixels.shape = [new_width,new_height,4];
|
||||
pixels.stride[1] = 4 * new_width;
|
||||
|
||||
return pixels;
|
||||
}
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype) {
|
||||
// This output is accesible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
changePixel: changePixel,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user