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

Commit

Permalink
config: move preview options to it's own settings menu
Browse files Browse the repository at this point in the history
- also use a select box to choose a preview mode

Change-Id: Ice3a7b69562ba64c2e41836141981a997b8eba50
  • Loading branch information
andi34 committed Nov 14, 2020
1 parent db3cd60 commit 8084c97
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 94 deletions.
2 changes: 1 addition & 1 deletion api/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
$newConfig['login_password'] = NULL;
}

if (!$newConfig['previewFromCam']) {
if ($newConfig['preview_mode'] != 'device_cam') {
$newConfig['previewCamTakesPic'] = false;
}

Expand Down
2 changes: 1 addition & 1 deletion api/takePic.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function takePicture($filename)
$demoFolder . $devImg[array_rand($devImg)],
$filename
);
} elseif ($config['previewFromCam'] && $config['previewCamTakesPic']) {
} elseif ($config['preview_mode'] === 'device_cam' && $config['previewCamTakesPic']) {
$data = $_POST['canvasimg'];
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
Expand Down
25 changes: 14 additions & 11 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,30 @@
// control countdown timer between collage pictures in seconds
$config['collage_cntdwn_time'] = '3';
$config['continuous_collage'] = true;
$config['allow_delete'] = true;
$config['allow_delete_from_gallery'] = true;


// J P E G Q U A L I T Y
$config['jpeg_quality_thumb'] = 60;
$config['jpeg_quality_chroma'] = 100;
$config['jpeg_quality_image'] = 100;


// P R E V I E W
// Please read https://github.com/andi34/photobooth/wiki/FAQ#how-to-use-a-live-stream-as-background-at-countdown
$config['previewFromCam'] = false;
// possible preview_mode values: none, device_cam, url
$config['preview_mode'] = 'none';
$config['previewCamTakesPic'] = false;
$config['previewCamFlipHorizontal'] = true;
$config['previewCamBackground'] = false;
$config['previewFromIPCam'] = false;
// possible ipCamPreviewRotation values: '0deg', '90deg', -90deg', '180deg', '45deg', '-45deg'
$config['ipCamPreviewRotation'] = '0deg';
$config['ipCamURL'] = null;
$config['videoWidth'] = '1280';
$config['videoHeight'] = '720';
// possible camera_mode values: "user", "environment"
$config['camera_mode'] = 'user';
$config['allow_delete'] = true;
$config['allow_delete_from_gallery'] = true;


// J P E G Q U A L I T Y
$config['jpeg_quality_thumb'] = 60;
$config['jpeg_quality_chroma'] = 100;
$config['jpeg_quality_image'] = 100;
$config['previewCamBackground'] = false;


// U S E R I N T E R F A C E
Expand Down
109 changes: 56 additions & 53 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,60 @@
'name' => 'continuous_collage',
'value' => $config['continuous_collage']
],
'previewFromCam' => [
'allow_delete' => [
'type' => 'checkbox',
'name' => 'allow_delete',
'value' => $config['allow_delete']
],
'allow_delete_from_gallery' => [
'type' => 'checkbox',
'name' => 'previewFromCam',
'value' => $config['previewFromCam']
'name' => 'allow_delete_from_gallery',
'value' => $config['allow_delete_from_gallery']
]
],
'jpeg_quality' => [
'jpeg_quality_image' => [
'type' => 'range',
'name' => 'jpeg_quality_image',
'placeholder' => $defaultConfig['jpeg_quality_image'],
'value' => $config['jpeg_quality_image'],
'range_min' => -1,
'range_max' => 100,
'range_step' => 1,
'unit' => 'percent'
],
'jpeg_quality_chroma' => [
'type' => 'range',
'name' => 'jpeg_quality_chroma',
'placeholder' => $defaultConfig['jpeg_quality_chroma'],
'value' => $config['jpeg_quality_chroma'],
'range_min' => -1,
'range_max' => 100,
'range_step' => 1,
'unit' => 'percent'
],
'jpeg_quality_thumb' => [
'type' => 'range',
'name' => 'jpeg_quality_thumb',
'placeholder' => $defaultConfig['jpeg_quality_thumb'],
'value' => $config['jpeg_quality_thumb'],
'range_min' => -1,
'range_max' => 100,
'range_step' => 1,
'unit' => 'percent'
]
],
'preview' => [
'mode' => [
'type' => 'select',
'name' => 'mode',
'placeholder' => $defaultConfig['preview_mode'],
'options' => [
'none' => 'None',
'device_cam' => 'from device cam',
'url' => 'from URL'
],
'value' => $config['preview_mode']
],
'previewCamTakesPic' => [
'type' => 'checkbox',
Expand All @@ -331,16 +381,6 @@
'name' => 'previewCamFlipHorizontal',
'value' => $config['previewCamFlipHorizontal']
],
'previewCamBackground' => [
'type' => 'checkbox',
'name' => 'previewCamBackground',
'value' => $config['previewCamBackground']
],
'previewFromIPCam' => [
'type' => 'checkbox',
'name' => 'previewFromIPCam',
'value' => $config['previewFromIPCam']
],
'ipCamPreviewRotation' => [
'type' => 'select',
'name' => 'ipCamPreviewRotation',
Expand Down Expand Up @@ -383,47 +423,10 @@
],
'value' => $config['camera_mode']
],
'allow_delete' => [
'type' => 'checkbox',
'name' => 'allow_delete',
'value' => $config['allow_delete']
],
'allow_delete_from_gallery' => [
'previewCamBackground' => [
'type' => 'checkbox',
'name' => 'allow_delete_from_gallery',
'value' => $config['allow_delete_from_gallery']
]
],
'jpeg_quality' => [
'jpeg_quality_image' => [
'type' => 'range',
'name' => 'jpeg_quality_image',
'placeholder' => $defaultConfig['jpeg_quality_image'],
'value' => $config['jpeg_quality_image'],
'range_min' => -1,
'range_max' => 100,
'range_step' => 1,
'unit' => 'percent'
],
'jpeg_quality_chroma' => [
'type' => 'range',
'name' => 'jpeg_quality_chroma',
'placeholder' => $defaultConfig['jpeg_quality_chroma'],
'value' => $config['jpeg_quality_chroma'],
'range_min' => -1,
'range_max' => 100,
'range_step' => 1,
'unit' => 'percent'
],
'jpeg_quality_thumb' => [
'type' => 'range',
'name' => 'jpeg_quality_thumb',
'placeholder' => $defaultConfig['jpeg_quality_thumb'],
'value' => $config['jpeg_quality_thumb'],
'range_min' => -1,
'range_max' => 100,
'range_step' => 1,
'unit' => 'percent'
'name' => 'previewCamBackground',
'value' => $config['previewCamBackground']
]
],
'user_interface' => [
Expand Down
27 changes: 13 additions & 14 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"gallery_pictureTime": "Milliseconds an image is displayed at slideshow",
"gallery_pswp_bgOpacity": "Background opacity",
"general": "General",
"general_camera_mode": "Camera facing mode",
"general_cheese_time": "Cheeeeeeeese!-Timer:",
"general_chroma_keying_variant": "Keying algorithm",
"general_chroma_size": "Chromakeying size",
Expand All @@ -70,8 +69,6 @@
"general_default_imagefilter": "Default image filter",
"general_disabled_filters": "Disabled image filters",
"general_file_naming": "File naming",
"general_ipCamPreviewRotation": "Rotate preview from URL",
"general_ipCamURL": "Preview-URL",
"general_language": "Language",
"general_photo_key": "Key code which triggers a photo",
"general_pictureRotation": "Rotate photo after taking (in degrees)",
Expand All @@ -83,8 +80,6 @@
"general_take_frame_path": "Frame",
"general_thumb_size": "Thumbnail size",
"general_time_to_live": "Show image after capture:",
"general_videoHeight": "Device cam picture height",
"general_videoWidth": "Device cam picture width",
"general_webserver_ip": "IP address of the Photobooth web server",
"general_wifi_ssid": "Wireless network name (SSID) used to access the photobooth",
"home": "Home",
Expand Down Expand Up @@ -152,7 +147,6 @@
"manual_gallery_db_check_time": "Add the interval (in seconds) the database get checked for new images.",
"manual_gallery_pictureTime": "Add a value which is used as milliseconds an image is displayed at slideshow inside the gallery.",
"manual_gallery_pswp_bgOpacity": "Background opacity, low values make the background more transparent.",
"manual_general_camera_mode": "Choose between front- or back facing camera mode of your device cam.",
"manual_general_cheese_time": "Set a time to display \"Cheeeeeeeese!\" after the countdown.",
"manual_general_chroma_keying_variant": "Choose between different chromakeying algorithms. <b>Please note:</b> Seriously.js requires a browser that supports WebGL.",
"manual_general_chroma_size": "Choose chromakeying size: S = max 1000px, M = max 1500px, L = max 2000px, XL = max 2500px",
Expand All @@ -165,8 +159,6 @@
"manual_general_default_imagefilter": "Choose an image filter which is applied by default after taking a picture.",
"manual_general_disabled_filters": "Choose filters which get removed from the available image filters.",
"manual_general_file_naming": "Choose between date formatted, numbered or random named images. For date formatted images, you can display the image with the date and time inside the gallery.",
"manual_general_ipCamPreviewRotation": "Choose to rotate the preview from URL.",
"manual_general_ipCamURL": "CSS style to use a stream from an URL for preview while countdown. <p>Example: <code>url(../img/bg_bluegray.jpg)</code></p>",
"manual_general_language": "Choose interface language.<p>If you're missing a language or like to help improving translations visit the <a href=\"https://github.com/andi34/photobooth/wiki/FAQ#how-to-update-or-add-translations\" target=\"_blank\">\"How to update or add translations?\"</a> inside the Photobooth Wiki for instructions.</p>",
"manual_general_photo_key": "Specify the key id to use that key to take a picture (e.g. 13 is the enter key). For example use <a href=\"https://keycode.info\" target=\"_blank\">https://keycode.info</a> to find out the key id.",
"manual_general_pictureRotation": "Enter a value which will set the degrees a picture is rotated after taking it.",
Expand All @@ -178,8 +170,6 @@
"manual_general_take_frame_path": "Enter the path of the frame which is applied to your picture after taking it.",
"manual_general_thumb_size": "Choose thumbnail size: XS = max 360px, S = max 540px, M = max 900px, L = max 1080px, XL = max 1260px",
"manual_general_time_to_live": "Enter a value used as milliseconds. This value defines the time your picture is visible on the result screen after taking a picture.",
"manual_general_videoHeight": "Enter a value which is used as height for preview by device cam.",
"manual_general_videoWidth": "Enter a value which is used as width for preview by device cam.",
"manual_general_webserver_ip": "Please define the IP address of the Photobooth web server to make the QR-Code working if you're accessing Photobooth via \"localhost\", \"127.0.0.1\" or if you have Photobooth installed inside a subfolder. <p>Example if Photobooth can be accessed directly: <code>192.168.0.50</code>.</p><p>Example if Photobooth is installed inside a subfolder: <code>192.168.0.50/photobooth</code>.</p>",
"manual_general_wifi_ssid": "Please define the wireless network name (SSID) to be used to access the Photobooth. The wireless network name (SSID) is displayed on the results page when the QR code is called up.",
"manual_image_preview_before_processing": "If enabled, images are preloaded and shown during filter processing.",
Expand Down Expand Up @@ -209,8 +199,12 @@
"manual_previewCamBackground": "If enabled, a stream from your device cam is used as background on start screen.",
"manual_previewCamFlipHorizontal": "If enabled, preview from device cam is flipped horizontal.",
"manual_previewCamTakesPic": "If enabled, a picture is taken from device cam instead executing the \"Take picture command\". Please note that the resolution depends on the given hight and width because it's acts like taking a screenshot.",
"manual_previewFromCam": "If enabled, a preview by your device cam is used at countdown. Preview by \"device cam\" will always use the camera of the device where Photobooth get opened in a Browser (e.g. on a tablet it will always show the tablet camera while on a smartphone it will always show the smartphone camera instead)! A secure origin or exception is required! You can find out how to set an exception <a href=\"https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339\" target=\"_blank\">here</a>.",
"manual_previewFromIPCam": "If enabled, a preview by defined url will be visible at countdown. Make sure to have a stream available you can use (e.g. from your Webcam, Smartphone Camera or Raspberry Pi Camera).",
"manual_preview_camera_mode": "Choose between front- or back facing camera mode of your device cam.",
"manual_preview_ipCamPreviewRotation": "Choose to rotate the preview from URL.",
"manual_preview_ipCamURL": "CSS style to use a stream from an URL for preview while countdown. <p>Example: <code>url(../img/bg_bluegray.jpg)</code></p>",
"manual_preview_mode": "Choose a live preview mode. By default live preview is disabled, you can choose between a preview at countdown by your device cam and a preview from a URL. Preview \"from device cam\" will always use the camera of the device where Photobooth get opened in a Browser (e.g. on a tablet it will always show the tablet camera while on a smartphone it will always show the smartphone camera instead)! A secure origin or exception is required! You can find out how to set an exception <a href=\"https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339\" target=\"_blank\">here</a>.",
"manual_preview_videoHeight": "Enter a value which is used as height for preview by device cam.",
"manual_preview_videoWidth": "Enter a value which is used as width for preview by device cam.",
"manual_print_auto_print_delay": "Enter in milliseconds by which the automatic printing of the image is delayed.",
"manual_print_crop_height": "Enter a value for the height which is used for the picture if \"Crop picture at print\" is enabled.",
"manual_print_crop_width": "Enter a value for the width which is used for the picture if \"Crop picture at print\" is enabled.",
Expand Down Expand Up @@ -290,11 +284,16 @@
"percent": "%",
"polaroid_effect": "Polaroid effect",
"preserve_exif_data": "Preserve EXIF data",
"preview": "Live preview",
"previewCamBackground": "Use stream from device cam as background",
"previewCamFlipHorizontal": "Flip image from device cam horizontally",
"previewCamTakesPic": "Device cam takes picture",
"previewFromCam": "See preview by device cam",
"previewFromIPCam": "Preview from URL",
"preview_camera_mode": "Camera facing mode",
"preview_ipCamPreviewRotation": "Rotate preview from URL",
"preview_ipCamURL": "Preview-URL",
"preview_mode": "Preview mode",
"preview_videoHeight": "Device cam picture height",
"preview_videoWidth": "Device cam picture width",
"print": "Print",
"print_auto_print_delay": "Delay automatic printing of the image",
"print_crop_height": "New height at print (px)",
Expand Down
19 changes: 5 additions & 14 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,9 @@ const photoBooth = (function () {
photoStyle = 'collage';
}

if (config.previewFromCam) {
if (config.preview_mode === 'device_cam') {
api.startVideo('view');
}

if (config.previewFromIPCam) {
} else if (config.preview_mode === 'url') {
$('#ipcam--view').show();
$('#ipcam--view').addClass('streaming');
}
Expand Down Expand Up @@ -263,14 +261,9 @@ const photoBooth = (function () {
.appendTo('.cheese');
}

if (config.previewFromCam && config.previewCamTakesPic && !api.stream && !config.dev) {
if (config.preview_mode === 'device_cam' && config.previewCamTakesPic && !api.stream && !config.dev) {
console.log('No preview by device cam available!');

if (config.previewFromIPCam) {
$('#ipcam--view').removeClass('streaming');
$('#ipcam--view').hide();
}

api.errorPic({
error: 'No preview by device cam available!'
});
Expand All @@ -293,16 +286,14 @@ const photoBooth = (function () {
ioClient.emit('photobooth-socket', 'in progress');
}

if (config.previewFromCam) {
if (config.preview_mode === 'device_cam') {
if (config.previewCamTakesPic && !config.dev) {
videoSensor.width = videoView.videoWidth;
videoSensor.height = videoView.videoHeight;
videoSensor.getContext('2d').drawImage(videoView, 0, 0);
}
api.stopVideo('view');
}

if (config.previewFromIPCam) {
} else if (config.preview_mode === 'url') {
$('#ipcam--view').removeClass('streaming');
$('#ipcam--view').hide();
}
Expand Down

0 comments on commit 8084c97

Please sign in to comment.