Skip to content

Commit bba9e0a

Browse files
authored
feat: support diffrent collage video preview size (#1309)
* fixes #902 support different collage video preview size * add i18n keys
1 parent 7e3753b commit bba9e0a

File tree

4 files changed

+60
-8
lines changed

4 files changed

+60
-8
lines changed

assets/js/preview.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ const photoboothPreview = (function () {
3030
DEVICE: 'device_cam',
3131
URL: 'url'
3232
},
33-
webcamConstraints = {
34-
audio: false,
35-
video: {
36-
width: config.preview.videoWidth,
37-
height: config.preview.videoHeight,
38-
facingMode: config.preview.camera_mode
39-
}
40-
},
4133
api = {};
4234

4335
let pid,
@@ -84,6 +76,30 @@ const photoboothPreview = (function () {
8476
return;
8577
}
8678

79+
const videoWidthDefault = config.preview.videoWidth;
80+
const videoHeightDefault = config.preview.videoHeight;
81+
let videoWidth = videoWidthDefault;
82+
let videoHeight = videoHeightDefault;
83+
84+
// Support diffrent preview video sizes for collage mode
85+
if (photoBooth.photoStyle === 'collage') {
86+
if (config.preview.videoWidth_collage > 0) {
87+
videoWidth = config.preview.videoWidth_collage;
88+
}
89+
if (config.preview.videoHeight_collage > 0) {
90+
videoHeight = config.preview.videoHeight_collage;
91+
}
92+
}
93+
94+
const webcamConstraints = {
95+
audio: false,
96+
video: {
97+
width: videoWidth,
98+
height: videoHeight,
99+
facingMode: config.preview.camera_mode
100+
}
101+
};
102+
87103
getMedia
88104
.call(navigator.mediaDevices, webcamConstraints)
89105
.then(function (stream) {

lib/configsetup.inc.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,20 @@
14791479
'placeholder' => $defaultConfig['preview']['videoHeight'],
14801480
'value' => $config['preview']['videoHeight'],
14811481
],
1482+
'preview_videoWidth_collage' => [
1483+
'view' => 'expert',
1484+
'type' => 'number',
1485+
'name' => 'preview[videoWidth_collage]',
1486+
'placeholder' => $defaultConfig['preview']['videoWidth_collage'],
1487+
'value' => $config['preview']['videoWidth_collage'],
1488+
],
1489+
'preview_videoHeight_collage' => [
1490+
'view' => 'expert',
1491+
'type' => 'number',
1492+
'name' => 'preview[videoHeight_collage]',
1493+
'placeholder' => $defaultConfig['preview']['videoHeight_collage'],
1494+
'value' => $config['preview']['videoHeight_collage'],
1495+
],
14821496
'preview_camera_mode' => [
14831497
'type' => 'select',
14841498
'name' => 'preview[camera_mode]',

resources/lang/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@
562562
"manual:preview:preview_url_delay": "Define a time to delay the visibility of the preview from URL. This might be needed if the preview URL is not ready early enough.",
563563
"manual:preview:preview_videoHeight": "Enter a value which is used as height for preview by device cam.",
564564
"manual:preview:preview_videoWidth": "Enter a value which is used as width for preview by device cam.",
565+
"manual:preview:preview_videoHeight_collage": "Enter a value which is used as height for preview by device cam while taking a collage.",
566+
"manual:preview:preview_videoWidth_collage": "Enter a value which is used as width for preview by device cam while taking a collage.",
565567
"manual:print:button_show_cups": "Show a button on startpage to easily access CUPS (Common Unix Printing System).",
566568
"manual:print:button_show_printUnlock": "Show a button on start page to unlock print once print got locked.",
567569
"manual:print:max_multiple_prints": "If greater than 1 a dialog will appear showing the user how many copies to print. This settings define the maximum number of copies can be printed each time the button is pressed.",
@@ -782,6 +784,8 @@
782784
"preview:preview_url_delay": "Delay visibility of preview from URL",
783785
"preview:preview_videoHeight": "Device cam picture height",
784786
"preview:preview_videoWidth": "Device cam picture width",
787+
"preview:preview_videoHeight_collage": "Device cam picture height while taking a collage",
788+
"preview:preview_videoWidth_collage": "Device cam picture width while taking a collage",
785789
"previewTest": "Preview test",
786790
"previous_element": "Previous",
787791
"print": "Print",

src/Configuration/PhotoboothConfiguration.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,24 @@ protected function addPreview(): NodeDefinition
601601
->end()
602602
->integerNode('videoHeight')
603603
->defaultValue(720)
604+
->beforeNormalization()
605+
->ifString()
606+
->then(function (string $value): int {
607+
return intval($value);
608+
})
609+
->end()
610+
->end()
611+
->integerNode('videoWidth_collage')
612+
->defaultValue(1280)
613+
->beforeNormalization()
614+
->ifString()
615+
->then(function (string $value): int {
616+
return intval($value);
617+
})
618+
->end()
619+
->end()
620+
->integerNode('videoHeight_collage')
621+
->defaultValue(720)
604622
->beforeNormalization()
605623
->ifString()
606624
->then(function (string $value): int { return intval($value); })

0 commit comments

Comments
 (0)