Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Feature: livekeying #157

Merged
merged 37 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bebbfb8
Added livechromakeying
Nov 8, 2020
c6827b0
eslint & formatting fixes
andi34 Dec 6, 2020
9ecd340
takeChroma: blur button after taking a picture
andi34 Dec 6, 2020
2e7271a
live chroma: correct processing message
andi34 Dec 6, 2020
cdff34a
live chroma: add reload button, move button functions out of core.js,…
andi34 Dec 6, 2020
cca577f
live chroma: only allow to take a picture if a background was set
andi34 Dec 6, 2020
9a366f6
live chroma: improvements and robustness
andi34 Dec 6, 2020
f845aac
live chroma: hide backgrounds while taking a picture
andi34 Dec 6, 2020
565e0cc
live chroma: only save the image once
andi34 Dec 6, 2020
7958f42
live chroma: allow to delete picture
andi34 Dec 6, 2020
ba574ca
live chroma: add close button, reposition reload button
andi34 Dec 6, 2020
3c6187f
live chroma: fix preview at countdown
andi34 Dec 6, 2020
a3459aa
core: cleanup cheese message selection
andi34 Dec 7, 2020
ac5ee16
live chroma: fix eslint issue, hide & show info message as needed
andi34 Dec 8, 2020
34bc835
live chroma: adjust info message style, move reload button
andi34 Dec 8, 2020
163e879
sass: move email rules to own partial style
andi34 Dec 9, 2020
b450286
live chroma: allow access to gallery
andi34 Dec 9, 2020
07b4c60
live chroma: add some padding between top buttons and canvasWrapper
andi34 Dec 9, 2020
bb24655
live chroma: only add keyed image to gallery
andi34 Dec 10, 2020
79bd703
live chroma: add the right image to gallery
andi34 Dec 10, 2020
f566c80
admin (keying): move keying options to own submenu
andi34 Dec 10, 2020
c65e4be
live chroma: add option to show original and keyed image inside gallery
andi34 Dec 10, 2020
3567748
api (fix): respect keep images config
andi34 Dec 10, 2020
410ca9a
api (deletePhoto): no need to check chroma keying config
andi34 Dec 10, 2020
682dd27
live chroma: only keep images as needed
andi34 Dec 10, 2020
82fe4c2
feature (chroma keying): allow to define background path used for chr…
andi34 Dec 10, 2020
700f4ea
fix (lang): fix wrong manual translation string
andi34 Dec 10, 2020
a338c42
scripts (pack-build): add livechroma.php
andi34 Dec 10, 2020
502756c
live chroma: respect gallery config
andi34 Dec 10, 2020
5c38080
enhance (delete): add a request before a picture gets deleted
andi34 Dec 10, 2020
94033dc
live chroma: add request before a picture gets deleted
andi34 Dec 10, 2020
6ee7c33
live chroma: allow to use livechroma.php as start page
andi34 Dec 10, 2020
ecf2d83
live chroma: allow to use "Key code which triggers a photo" option
andi34 Dec 11, 2020
d5590b0
Added styling for RPI 10.1 screen
joiyco Dec 14, 2020
b45870b
style (live chroma): cleanup & adjustments
andi34 Dec 19, 2020
0969395
style (live chroma): more adjustments, bigger background images
andi34 Dec 19, 2020
82fb261
optimize canvas size on chroma keying and live keying
andi34 Dec 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions api/applyEffects.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
$thumb_size = substr($config['thumb_size'], 0, -2);
$chroma_size = substr($config['chroma_size'], 0, -2);

if (isset($_POST['isCollage']) && $_POST['isCollage'] === 'true') {
if (!isset($_POST['style'])) {
die(json_encode([
'error' => 'No style provided'
]));
}

if ($_POST['style'] === 'collage') {
$collageBasename = substr($filename_tmp, 0, -4);
$collageSrcImagePaths = [];

Expand Down Expand Up @@ -108,7 +114,7 @@
$imageModified = true;
}

if ($config['take_frame'] && $_POST['isCollage'] !== 'true') {
if ($config['take_frame'] && $_POST['style'] !== 'collage') {
$frame = imagecreatefrompng($frame_path);
$frame = resizePngImage($frame, imagesx($imageResource), imagesy($imageResource));
$x = (imagesx($imageResource)/2) - (imagesx($frame)/2);
Expand All @@ -117,7 +123,7 @@
$imageModified = true;
}

if ($config['chroma_keying']) {
if ($config['chroma_keying'] || $_POST['style'] === 'chroma') {
$chromaCopyResource = resizeImage($imageResource, $chroma_size, $chroma_size);
imagejpeg($chromaCopyResource, $filename_keying, $config['jpeg_quality_chroma']);
imagedestroy($chromaCopyResource);
Expand Down Expand Up @@ -155,11 +161,18 @@
imagedestroy($imageResource);

// insert into database
appendImageToDB($file);
if ($_POST['style'] !== 'chroma' || $_POST['style'] === 'chroma' && $config['live_keying_show_all'] === true) {
appendImageToDB($file);
}

// Change permissions
chmod($filename_photo, octdec($picture_permissions));

if ($_POST['style'] === 'chroma' && $config['live_keying_show_all'] === false) {
unlink($filename_photo);
unlink($filename_thumb);
}

echo json_encode([
'file' => $file,
]);
14 changes: 6 additions & 8 deletions api/deletePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@
]));
}

if ($config['chroma_keying']) {
if (is_readable($filePathKeying)) {
if (!unlink ($filePathKeying)) {
die(json_encode([
'error' => 'Could not delete keying file',
]));
}
if (is_readable($filePathKeying)) {
if (!unlink ($filePathKeying)) {
die(json_encode([
'error' => 'Could not delete keying file',
]));
}
}

if ($config['keep_images']) {
if (!$config['keep_images']) {
if (is_readable($filePathTmp)) {
if (!unlink ($filePathTmp)) {
die(json_encode([
Expand Down
7 changes: 7 additions & 0 deletions api/takePic.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ function takePicture($filename)
'current' => $number,
'limit' => $config['collage_limit'],
]));
} elseif ($_POST['style'] === 'chroma') {
takePicture($filename_tmp);
die(json_encode([
'success' => 'chroma',
'file' => $file,
]));

} else {
die(json_encode([
'error' => 'Invalid photo style provided',
Expand Down
4 changes: 2 additions & 2 deletions chromakeying.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
<body data-main-image="<?=$mainimage?>">
<div class="chromawrapper">
<?php if ($keying_possible): ?>
<div class="canvasWrapper">
<div class="canvasWrapper initial">
<canvas id="mainCanvas"></canvas>
</div>

<div style="padding-top:10px;text-align:center;">
<?php
$dir = join(DIRECTORY_SEPARATOR, ['resources', 'img', 'background']) . DIRECTORY_SEPARATOR;
$dir = $config['keying_background_path'] . DIRECTORY_SEPARATOR;
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".","..")) && !is_dir($dir.$value)) {
Expand Down
16 changes: 11 additions & 5 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
$config['polaroid_rotation'] = '0';
$config['take_frame'] = false;
$config['take_frame_path'] = '../resources/img/frames/frame.png';
$config['chroma_keying'] = false;
// possible chroma_keying_variant values: 'marvinj', 'seriouslyjs'
$config['chroma_keying_variant'] = 'marvinj';
// possible chroma_size values: '1000px', '1500px', '2000px', '2500px'
$config['chroma_size'] = '1500px';
$config['use_collage'] = true;
$config['take_collage_frame'] = false;
$config['take_collage_frame_always'] = false;
Expand Down Expand Up @@ -148,6 +143,17 @@
$config['event']['symbol'] = 'fa-heart-o';


// K E Y I N G
$config['chroma_keying'] = false;
// possible chroma_keying_variant values: 'marvinj', 'seriouslyjs'
$config['chroma_keying_variant'] = 'marvinj';
// possible chroma_size values: '1000px', '1500px', '2000px', '2500px'
$config['chroma_size'] = '1500px';
$config['keying_background_path'] = 'resources/img/background';
$config['live_keying_show_all'] = false;
$config['use_live_keying'] = false;


// P R I N T
$config['use_print_result'] = false;
$config['use_print_gallery'] = false;
Expand Down
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

$images = getImagesFromDB();
$imagelist = ($config['newest_first'] === true) ? array_reverse($images) : $images;

if ($config['use_live_keying']):
header("location: livechroma.php");
endif;
?>
<!DOCTYPE html>
<html>
Expand Down
72 changes: 45 additions & 27 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,33 +236,6 @@
'name' => 'take_frame_path',
'value' => htmlentities($config['take_frame_path'])
],
'chroma_keying' => [
'type' => 'checkbox',
'name' => 'chroma_keying',
'value' => $config['chroma_keying']
],
'chroma_keying_variant' => [
'type' => 'select',
'name' => 'chroma_keying_variant',
'placeholder' => $defaultConfig['chroma_keying_variant'],
'options' => [
'marvinj' => 'MarvinJ',
'seriouslyjs' => 'Seriously.js'
],
'value' => $config['chroma_keying_variant']
],
'chroma_size' => [
'type' => 'select',
'name' => 'chroma_size',
'placeholder' => $defaultConfig['chroma_size'],
'options' => [
'1000px' => 'S',
'1500px' => 'M',
'2000px' => 'L',
'2500px' => 'XL'
],
'value' => $config['chroma_size']
],
'use_collage' => [
'type' => 'checkbox',
'name' => 'use_collage',
Expand Down Expand Up @@ -690,6 +663,51 @@
'value' => $config['event']['symbol']
]
],
'keying' => [
'chroma_keying' => [
'type' => 'checkbox',
'name' => 'chroma_keying',
'value' => $config['chroma_keying']
],
'chroma_keying_variant' => [
'type' => 'select',
'name' => 'chroma_keying_variant',
'placeholder' => $defaultConfig['chroma_keying_variant'],
'options' => [
'marvinj' => 'MarvinJ',
'seriouslyjs' => 'Seriously.js'
],
'value' => $config['chroma_keying_variant']
],
'chroma_size' => [
'type' => 'select',
'name' => 'chroma_size',
'placeholder' => $defaultConfig['chroma_size'],
'options' => [
'1000px' => 'S',
'1500px' => 'M',
'2000px' => 'L',
'2500px' => 'XL'
],
'value' => $config['chroma_size']
],
'background_path' => [
'type' => 'input',
'placeholder' => $defaultConfig['keying_background_path'],
'name' => 'keying_background_path',
'value' => htmlentities($config['keying_background_path'])
],
'live_keying_show_all' => [
'type' => 'checkbox',
'name' => 'live_keying_show_all',
'value' => $config['live_keying_show_all']
],
'use_live_keying' => [
'type' => 'checkbox',
'name' => 'use_live_keying',
'value' => $config['use_live_keying']
]
],
'print' => [
'use_print_result' => [
'type' => 'checkbox',
Expand Down
147 changes: 147 additions & 0 deletions livechroma.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php
require_once('lib/config.php');
require_once('lib/db.php');

$images = getImagesFromDB();
$imagelist = ($config['newest_first'] === true) ? array_reverse($images) : $images;
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
<meta name="msapplication-TileColor" content="<?=$config['colors']['primary']?>">
<meta name="theme-color" content="<?=$config['colors']['primary']?>">

<!-- Favicon + Android/iPhone Icons -->
<link rel="apple-touch-icon" sizes="180x180" href="resources/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="resources/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="resources/img/favicon-16x16.png">
<link rel="manifest" href="resources/img/site.webmanifest">
<link rel="mask-icon" href="resources/img/safari-pinned-tab.svg" color="#5bbad5">

<!-- Fullscreen Mode on old iOS-Devices when starting photobooth from homescreen -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />

<link rel="stylesheet" href="node_modules/normalize.css/normalize.css" />
<link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.css" />
<link rel="stylesheet" href="vendor/PhotoSwipe/dist/photoswipe.css" />
<link rel="stylesheet" href="vendor/PhotoSwipe/dist/default-skin/default-skin.css" />
<link rel="stylesheet" href="resources/css/live_chromakeying.css" />
<?php if ($config['gallery_bottom_bar']): ?>
<link rel="stylesheet" href="resources/css/photoswipe-bottom.css" />
<?php endif; ?>
<?php if ($config['rounded_corners']): ?>
<link rel="stylesheet" href="resources/css/rounded.css" />
<?php endif; ?>
</head>
<body>
<div class="chromawrapper">
<div class="top-bar">
<?php if (!$config['use_live_keying']): ?>
<a href="index.php" class="btn btn--small btn--flex home"><i class="fa fa-times"></i></a>
<?php endif; ?>

<?php if ($config['show_gallery']): ?>
<a class="gallerybtn btn btn--small btn--flex" href="#"><i class="fa fa-th"></i> <span data-i18n="gallery"></span></a>
<?php endif; ?>

</div>

<div class="canvasWrapper initial">
<canvas id="mainCanvas"></canvas>
</div>

<div class="chromaNote">
<span data-i18n="chromaInfoBefore"></span>
</div>

<div class="stages" id="loader">
<div class="loaderInner">
<div class="spinner">
<i class="fa fa-cog fa-spin"></i>
</div>

<div id="ipcam--view"></div>

<video id="video--view" autoplay playsinline></video>

<div id="counter">
<canvas id="video--sensor"></canvas>
</div>
<div class="cheese"></div>
<div class="loading"></div>
</div>
</div>

<!-- Result Page -->
<div class="stages" id="result"></div>

<div class="backgrounds">
<?php
$dir = $config['keying_background_path'] . DIRECTORY_SEPARATOR;
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".","..")) && !is_dir($dir.$value)) {
echo '<img src="'.$dir.$value.'" class="backgroundPreview" onclick="setBackgroundImage(this.src)">';
}
}
?>
</div>

<div class="chroma-control-bar">
<a href="#" class="btn takeChroma"><i class="fa fa-camera"></i> <span data-i18n="takePhoto"></span></a>
<?php if ($config['allow_delete']): ?>
<a href="#" class="btn deletebtn"><i class="fa fa-trash"></i> <span data-i18n="delete"></span></a>
<?php endif; ?>
<a href="#" class="btn reloadPage"><i class="fa fa-refresh"></i> <span data-i18n="reload"></span></a>
</div>
<div>

<div id="wrapper">
<?php include('template/gallery.template.php'); ?>
</div>
<?php include('template/pswp.template.php'); ?>

<div class="send-mail">
<i class="fa fa-times" id="send-mail-close"></i>
<p data-i18n="insertMail"></p>
<form id="send-mail-form" style="margin: 0;">
<input class="mail-form-input" size="35" type="email" name="sendTo">
<input id="mail-form-image" type="hidden" name="image" value="">

<?php if ($config['send_all_later']): ?>
<input type="checkbox" id="mail-form-send-link" name="send-link" value="yes">
<label data-i18n="sendAllMail" for="mail-form-send-link"></label>
<?php endif; ?>

<button class="mail-form-input btn" name="submit" type="submit" value="Send"><span data-i18n="send"></span></button>
</form>

<div id="mail-form-message" style="max-width: 75%"></div>
</div>

<div class="modal" id="print_mesg">
<div class="modal__body"><span data-i18n="printing"></span></div>
</div>

<script src="node_modules/whatwg-fetch/dist/fetch.umd.js"></script>
<script type="text/javascript" src="api/config.php"></script>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="vendor/PhotoSwipe/dist/photoswipe.min.js"></script>
<script type="text/javascript" src="vendor/PhotoSwipe/dist/photoswipe-ui-default.min.js"></script>
<script type="text/javascript" src="resources/js/photoinit.js"></script>
<script type="text/javascript" src="resources/js/core.js"></script>
<?php if ($config['chroma_keying_variant'] === 'marvinj'): ?>
<script type="text/javascript" src="node_modules/marvinj/marvinj/release/marvinj-1.0.js"></script>
<?php else:?>
<script type="text/javascript" src="vendor/Seriously/seriously.js"></script>
<script type="text/javascript" src="vendor/Seriously/effects/seriously.chroma.js"></script>
<?php endif; ?>
<script type="text/javascript" src="resources/js/livechroma.js"></script>
<script type="text/javascript" src="resources/js/theme.js"></script>
<script src="node_modules/@andreasremdt/simple-translator/dist/umd/translator.min.js"></script>
<script type="text/javascript" src="resources/js/i18n.js"></script>
</body>
</html>
Loading