mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
Gl puppeteer (#1007)
* add geotiff Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * now running gl using localhost fixes #216 Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * modularize api and fix tests Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * finishing up Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add docs Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fixes Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fix benchmark.js Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
committed by
Jeffrey Warren
parent
4e43c9123a
commit
c3e8c3fb74
37
src/modules/_nomodule/gl-context.js
Normal file
37
src/modules/_nomodule/gl-context.js
Normal file
@@ -0,0 +1,37 @@
|
||||
module.exports = function runInBrowserContext(input, callback, step, options) {
|
||||
|
||||
// to ignore this from getting browserified
|
||||
const puppeteer = eval('require')('puppeteer');
|
||||
|
||||
//Stripped down version of options which is serializable
|
||||
var minOptions = require("lodash").cloneDeep(options);
|
||||
minOptions.step = options.step.name;
|
||||
|
||||
var obj = { input: input, modOptions: minOptions }
|
||||
|
||||
puppeteer.launch().then(function(browser) {
|
||||
browser.newPage().then(page => {
|
||||
/* Maybe there is a better way to this, loading the page coz localstorage API
|
||||
is not available otherwise */
|
||||
page.goto("https://google.com").then(() => {
|
||||
page.addScriptTag({ path: require('path').join(__dirname, '../../../dist/image-sequencer.js') }).then(() => {
|
||||
page.evaluate((options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var sequencer = ImageSequencer();
|
||||
sequencer.loadImage(options.input.src);
|
||||
sequencer.addSteps(options.modOptions.step, options.modOptions);
|
||||
sequencer.run(function cb(out) {
|
||||
resolve(sequencer.steps[1].output.src)
|
||||
});
|
||||
})
|
||||
}, obj).then(el => {
|
||||
browser.close().then(() => {
|
||||
step.output = { src: el, format: input.format };
|
||||
callback();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user