Browse Source

footer added - process during build

bob
P.BARRY 10 years ago
parent
commit
ba058493ec
6 changed files with 33 additions and 31 deletions
  1. 9
      app.js
  2. BIN
      public/img/footer/cloclo.jpg
  3. BIN
      public/img/footer/m-cloclo.jpg
  4. 19
      tools/tools-gphoto2.js
  5. 34
      tools/tools-photobooth.js
  6. 2
      views/index.ejs

9
app.js

@ -82,13 +82,13 @@ module.exports = app;
function BOB_initConfig() { function BOB_initConfig() {
// Config // Config
var cfgConfig = { var cfgConfig = {
background : '#fff0ff',
margins : 0.01,
background : '#ffffff',
margins : 0.005,
style : 'default', style : 'default',
nbPicture : 4, nbPicture : 4,
cropSize : { cropSize : {
width : 900, width : 900,
height : 1125
height : 1200
}, },
pictNames : [], pictNames : [],
layout : [], layout : [],
@ -98,7 +98,8 @@ function BOB_initConfig() {
template : "", template : "",
prebuilt : "", prebuilt : "",
original : "" original : ""
}
},
footer : BOB_mod_path.resolve(__dirname, './public/img/footer', 'm-cloclo.jpg')
}; };
// Init PATH // Init PATH
cfgConfig.paths.final = BOB_mod_path.resolve(__dirname, './public/img/final'); cfgConfig.paths.final = BOB_mod_path.resolve(__dirname, './public/img/final');

BIN
public/img/footer/cloclo.jpg

Before After
Width: 1240  |  Height: 1778  |  Size: 266 KiB

BIN
public/img/footer/m-cloclo.jpg

Before After
Width: 1600  |  Height: 333  |  Size: 58 KiB

19
tools/tools-gphoto2.js

@ -36,7 +36,12 @@ BOB_module.getConfig = function(pCallback) {
BOB_module.takePicture = function(pBoothId, pPictId, pCallback) { BOB_module.takePicture = function(pBoothId, pPictId, pCallback) {
var destPath = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId); var destPath = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId);
var pictPath = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]);
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]);
BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId));
BOB_upCameraReference(function() { BOB_upCameraReference(function() {
if( BOB_var_camera === null ) { if( BOB_var_camera === null ) {
@ -49,16 +54,16 @@ BOB_module.takePicture = function(pBoothId, pPictId, pCallback) {
// Else write file on ddisk // Else write file on ddisk
} else { } else {
BOB_mod_mkdirp(destPath, function() { BOB_mod_mkdirp(destPath, function() {
BOB_mod_fs.writeFile(pictPath, pData, function(pErr) {
BOB_mod_gm(pictPath)
BOB_mod_fs.writeFile(pictOrig, pData, function(pErr) {
BOB_mod_gm(pictOrig)
.autoOrient() .autoOrient()
.gravity('Center') .gravity('Center')
.resize(BOB_cfg_config.cropSize.width, BOB_cfg_config.cropSize.height, "^")
.crop(BOB_cfg_config.cropSize.width, BOB_cfg_config.cropSize.height)
// .resize(BOB_cfg_config.cropSize.width, BOB_cfg_config.cropSize.height, "^")
// .crop(BOB_cfg_config.cropSize.width, BOB_cfg_config.cropSize.height)
// .modulate(100, 0) // .modulate(100, 0)
// .contrast(+2) // .contrast(+2)
.write(dstPict, function(pErr) {
return pCallback(pErr, pictPath)
.write(pictOrig, function(pErr) {
return pCallback(pErr, pictPblt)
}) })
}); });
}) })

34
tools/tools-photobooth.js

@ -19,13 +19,11 @@ BOB_module.getBoothList = function(pFrom, pCallback) {
} }
BOB_module.buildBooth = function(pBoothId, pCallback) { BOB_module.buildBooth = function(pBoothId, pCallback) {
var index = 0;
var funcResizeArray = [];
// Create output prebuild directory
BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId)); BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId));
BOB_cfg_config.pictNames.forEach(function(pPictName) {
funcResizeArray.push(function(pCb) {
// Resize pictures
BOB_mod_async.mapSeries(BOB_cfg_config.pictNames,
function(pPictName, pCb) {
var srcPict = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId, pPictName); var srcPict = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId, pPictName);
var dstPict = BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId, pPictName); var dstPict = BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId, pPictName);
@ -39,21 +37,17 @@ BOB_module.buildBooth = function(pBoothId, pCallback) {
// .modulate(100, 0) // .modulate(100, 0)
// .contrast(+2) // .contrast(+2)
.write(dstPict, function(pErr) { .write(dstPict, function(pErr) {
if(pErr) console.log("Failed to resize picture", pErr)
pCb() pCb()
}) })
})
})
BOB_mod_async.parallel(
funcResizeArray,
function(pErr, pData) {
},
function(pErr) {
console.log("Building booth") console.log("Building booth")
switch(BOB_cfg_config.style) { switch(BOB_cfg_config.style) {
default : default :
BOB_generateBooth(pBoothId, 'default', pCallback); BOB_generateBooth(pBoothId, 'default', pCallback);
} }
}
)
})
} }
function BOB_generateBooth(pBoothId, pType, pCallback) { function BOB_generateBooth(pBoothId, pType, pCallback) {
@ -67,6 +61,8 @@ function BOB_generateBooth(pBoothId, pType, pCallback) {
outPict.fill(BOB_cfg_config.background); outPict.fill(BOB_cfg_config.background);
outPict.drawRectangle(0, 0, BOB_cfg_config.booths[pType].resolution.width, BOB_cfg_config.booths[pType].resolution.height); outPict.drawRectangle(0, 0, BOB_cfg_config.booths[pType].resolution.width, BOB_cfg_config.booths[pType].resolution.height);
outPict.draw('image Over 0,2080 1600,300 \''+BOB_cfg_config.footer+'\'');
BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) { BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) {
var cmdDraw = 'image Over'; var cmdDraw = 'image Over';
cmdDraw += ' '+BOB_cfg_config.booths[pType].layout[pIndex].x; cmdDraw += ' '+BOB_cfg_config.booths[pType].layout[pIndex].x;
@ -79,9 +75,9 @@ function BOB_generateBooth(pBoothId, pType, pCallback) {
outPict.draw(cmdDraw); outPict.draw(cmdDraw);
}) })
outPict.fill("#000000");
outPict.pointSize(40);
outPict.draw('text 1900,3850 "'+printedDate.toUTCString()+'"');
outPict.fill("#666");
outPict.pointSize(20);
outPict.draw('text 1250,2350 "'+printedDate.toUTCString()+'"');
outPict.write(finalPict, function (pErr) { outPict.write(finalPict, function (pErr) {
if( pErr ) { if( pErr ) {
@ -140,8 +136,8 @@ function BOB_updateConfig() {
function BOB_generatePictLayout(pBoothName) { function BOB_generatePictLayout(pBoothName) {
var index = 0; var index = 0;
var marginX = 50;
var marginY = 50;
var marginX = 20;
var marginY = 20;
var pictWidth = ( BOB_cfg_config.booths[pBoothName].resolution.width - 3 * marginX ) / 2; var pictWidth = ( BOB_cfg_config.booths[pBoothName].resolution.width - 3 * marginX ) / 2;
var pictHeight = parseInt(pictWidth * BOB_cfg_config.cropSize.height / BOB_cfg_config.cropSize.width); var pictHeight = parseInt(pictWidth * BOB_cfg_config.cropSize.height / BOB_cfg_config.cropSize.width);

2
views/index.ejs

@ -133,7 +133,7 @@ function BOB_displayPictPreview(pBoothId, pPictureId, pCallback) {
$('#idBoothPanel').fadeIn(50, function() { $('#idBoothPanel').fadeIn(50, function() {
pCallback() pCallback()
}) })
}, 2000)
}, 4000)
}) })
} }

Loading…
Cancel
Save