diff --git a/app.js b/app.js index f771ffa..f4a9083 100644 --- a/app.js +++ b/app.js @@ -99,7 +99,7 @@ function BOB_initConfig() { prebuilt : "", original : "" }, - footer : BOB_mod_path.resolve(__dirname, './public/img/footer', 'm-cloclo.jpg') + footer : BOB_mod_path.resolve(__dirname, './public/img/footer', 'm-clotilde60.jpg') }; // Init PATH cfgConfig.paths.final = BOB_mod_path.resolve(__dirname, './public/img/final'); diff --git a/public/img/footer/m-clotilde60.jpg b/public/img/footer/m-clotilde60.jpg new file mode 100644 index 0000000..34fced6 Binary files /dev/null and b/public/img/footer/m-clotilde60.jpg differ diff --git a/public/img/footer/m-clotilde60.xcf b/public/img/footer/m-clotilde60.xcf new file mode 100644 index 0000000..c1a0aeb Binary files /dev/null and b/public/img/footer/m-clotilde60.xcf differ diff --git a/routes/index.js b/routes/index.js index cbc477d..7d70136 100644 --- a/routes/index.js +++ b/routes/index.js @@ -15,14 +15,24 @@ var BOB_var_boothInProgress = 0; var BOB_var_gamepad = require("gamepad"); var BOB_var_ipAddress = '127.0.0.1'; -var BOB_var_path = "/home/troll/workspace/bobinoscope"; +var BOB_var_path = "/home/cocoon/workspace/bobinoscope"; -BOB_mod_mkdirp.sync("public/printer/todo"); -BOB_mod_mkdirp.sync("public/printer/done"); +var BOB_var_killZone = { + top : 2, + bottom : 2, + left : 25, + right : 25 +} + +BOB_mod_mkdirp.sync(BOB_var_path+"/public/printer/todo"); +BOB_mod_mkdirp.sync(BOB_var_path+"/public/printer/done"); /* GET home page. */ BOB_mod_router.get('/bobinoscope', function(req, res, next) { - res.render('index', {serverIpAddress: BOB_var_ipAddress}); + res.render('index', { + serverIpAddress: BOB_var_ipAddress, + killZone : BOB_var_killZone + }); }); /* GET view page. */ BOB_mod_router.get('/', function(req, res, next) { @@ -69,7 +79,7 @@ BOB_mod_router.get('/print/bobinogramme/:pictId', function(req, res, next) { }); BOB_mod_router.get('/print/list/todo', function(req, res, next) { - var todoPath = BOB_mod_path.join(BOB_var_path, '/public/img/final/'+req.params.pictId); + var todoPath = BOB_mod_path.join(BOB_var_path, '/public/printer/todo'); BOB_mod_fs.readdir(todoPath, function(pErr, pList) { res.json({error: pErr, todos: pList}) }) diff --git a/tools/tools-gphoto2.js b/tools/tools-gphoto2.js index 02ab49b..c92d2f9 100644 --- a/tools/tools-gphoto2.js +++ b/tools/tools-gphoto2.js @@ -1,10 +1,12 @@ var BOB_mod_gm = require('gm').subClass({ imageMagick: true }); -var BOB_mod_gphoto2 = require('gphoto2'); -var BOB_var_gphoto = new BOB_mod_gphoto2.GPhoto2(); +// var BOB_mod_gphoto2 = require('gphoto2'); +// var BOB_var_gphoto = new BOB_mod_gphoto2.GPhoto2(); var BOB_mod_fs = require('fs'); var BOB_mod_path = require('path'); var BOB_mod_mkdirp = require('mkdirp'); +var BOB_mod_exec = require('child_process').exec; + var BOB_cfg_config = null; var BOB_var_camera = null; @@ -13,22 +15,29 @@ var BOB_module = {}; BOB_upCameraReference(function() {}); +function BOB_takePicture(pCallback) { + BOB_mod_exec("gphoto2 --capture-image-and-download --filename=/tmp/bobine.jpg --force-overwrite", function(pErr, pStdout, pStderr) { + console.log("takjePixuter", pErr || pStdout || pStderr) + return pCallback(pErr) + }) +} + function BOB_upCameraReference(pCallback) { // List cameras / assign list item to variable to use below options - if( BOB_var_camera === null ) { - BOB_var_gphoto.list(function (list) { - if (list.length === 0) { - return pCallback(); - } else { - console.log(list) - BOB_var_camera = list[0]; - console.log(BOB_var_camera.model); - return pCallback(); - } - }) - } else { + //if( BOB_var_camera === null ) { + // BOB_var_gphoto.list(function (list) { + // if (list.length === 0) { + // return pCallback(); + // } else { + // console.log(list) + // BOB_var_camera = list[0]; + // console.log(BOB_var_camera.model); + // return pCallback(); + // } + // }) + //} else { return pCallback(); - } + //} } BOB_module.getConfig = function(pCallback) { @@ -41,21 +50,82 @@ BOB_module.takePicture = function(pBoothId, pPictId, pCallback) { var pictOrig = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); var pictPblt = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); + BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId)); + + console.log("new") + BOB_takePicture(function (pErr) { + // If error occurs + if( pErr ) { + return pCallback(pErr) + // Else write file on ddisk + } else { + BOB_mod_mkdirp(destPath, function() { + copyFile("/tmp/bobine.jpg", pictOrig, function(pErr) { + return pCallback(pErr, pictOrig) + }); + }) + } + }); +} + + +function copyFile(source, target, cb) { + var cbCalled = false; + + var rd = BOB_mod_fs.createReadStream(source); + rd.on("error", function(err) { + done(err); + }); + var wr = BOB_mod_fs.createWriteStream(target); + wr.on("error", function(err) { + done(err); + }); + wr.on("close", function(ex) { + done(); + }); + rd.pipe(wr); + + function done(err) { + if (!cbCalled) { + cb(err); + cbCalled = true; + } + } +} + +BOB_module.takePictureNpm = function(pBoothId, pPictId, pCallback) { + var destPath = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId); + var pbltPath = BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId); + var pictOrig = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); + var pictPblt = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); + +console.log("1"); BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId)); +console.log("2"); BOB_upCameraReference(function() { +console.log("3"); + if( BOB_var_camera === null ) { return pCallback("No camera found"); } else { +console.log("4"); + BOB_var_camera.takePicture({download: true}, function (pErr, pData) { // If error occurs if( pErr ) { return pCallback(pErr) // Else write file on ddisk } else { +console.log("5"); + BOB_mod_mkdirp(destPath, function() { +console.log("6"); + BOB_mod_fs.writeFile(pictOrig, pData, function(pErr) { +console.log("7"); + // BOB_mod_gm(pictOrig) // .autoOrient() // .gravity('Center') @@ -78,4 +148,4 @@ BOB_module.takePicture = function(pBoothId, pPictId, pCallback) { module.exports = function(pConfig) { BOB_cfg_config = pConfig; return BOB_module; -} \ No newline at end of file +} diff --git a/tools/tools-photobooth.js b/tools/tools-photobooth.js index 287fb1b..532a3cd 100644 --- a/tools/tools-photobooth.js +++ b/tools/tools-photobooth.js @@ -59,7 +59,7 @@ function BOB_generateBooth(pBoothId, pType, pCallback) { outPict.fill(BOB_cfg_config.background); outPict.drawRectangle(0, 0, BOB_cfg_config.booths[pType].resolution.width, BOB_cfg_config.booths[pType].resolution.height); // Draw footer - outPict.draw('image Over 0,2070 1600,280 \''+BOB_cfg_config.footer+'\''); + outPict.draw('image Over 0,2100 1600,250 \''+BOB_cfg_config.footer+'\''); BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) { var cmdDraw = 'image Over'; @@ -84,7 +84,7 @@ function BOB_generateBooth(pBoothId, pType, pCallback) { pCallback(pErr); } else { BOB_mod_gm(finalPict) - .resize(600, null) + .resize(400, null) .write(finalLdPict, function(pErr) { pCallback(pErr); }) diff --git a/views/index.ejs b/views/index.ejs index 08866ab..fdb463b 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -19,16 +19,29 @@