forked from andi34/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chromakeying.php
117 lines (105 loc) · 4.76 KB
/
chromakeying.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
require_once('lib/config.php');
if (empty($_GET['filename'])) {
die('No or invalid file provided');
}
if ($config['ui']['style'] === 'modern') {
$btnClass1 = 'round-btn';
$btnClass2 = 'round-btn';
} else {
$btnClass1 = 'btn btn--flex';
$btnClass2 = 'btn';
}
$filename = $_GET['filename'];
$keyingimage = $config['foldersRoot']['keying'] . DIRECTORY_SEPARATOR . $filename;
if (file_exists($keyingimage)) {
// Only jpg/jpeg are supported
$imginfo = getimagesize($keyingimage);
$mimetype = $imginfo['mime'];
if ($mimetype == 'image/jpg' || $mimetype == 'image/jpeg') {
$mainimage = $keyingimage;
$keying_possible = true;
} else {
$keying_possible = false;
$mainimage = 'resources/img/bg.jpg';
}
} else {
$keying_possible = false;
$mainimage = 'resources/img/bg.jpg';
}
?>
<!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="resources/css/<?php echo $config['ui']['style']; ?>_chromakeying.css" />
<?php if ($config['ui']['rounded_corners']): ?>
<link rel="stylesheet" href="resources/css/rounded.css" />
<?php endif; ?>
</head>
<body data-main-image="<?=$mainimage?>">
<div class="chromawrapper">
<?php if ($keying_possible): ?>
<div class="canvasWrapper initial">
<canvas id="mainCanvas"></canvas>
</div>
<div style="padding-top:10px;text-align:center;">
<?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 class="<?php echo $btnClass1; ?>" id="save-btn" href="#"><i class="fa fa-floppy-o"></i> <span data-i18n="save"></span></a>
<?php if ($config['print']['from_chromakeying']): ?>
<a class="<?php echo $btnClass1; ?>" id="print-btn" href="#"><i class="fa fa-print"></i> <span data-i18n="print"></span></a>
<?php endif; ?>
<a class="<?php echo $btnClass1; ?>" id="close-btn" href="#"><i class="fa fa-times"></i> <span data-i18n="close"></span></a>
</div>
<?php else:?>
<div style="text-align:center;padding-top:250px">
<h1 style="color: red;" data-i18n="keyingerror"></h1>
<a class="<?php echo $btnClass2; ?>" href="./"><span data-i18n="close"></span></a>
</div>
<?php endif; ?>
<div class="modal" id="print_mesg">
<div class="modal__body" id="print_mesg_text"><span data-i18n="printing"></span></div>
</div>
<div class="modal" id="save_mesg">
<div class="modal__body" id="save_mesg_text"><span data-i18n="saving"></span></div>
</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>
<?php if ($config['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/chromakeying.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>