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

Print optimizations and new auto print feature #109

Merged
merged 7 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion chromakeying.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<div class="chroma-control-bar">
<a class="btn btn--flex" id="save-btn" href="#"><i class="fa fa-floppy-o"></i> <span data-i18n="save"></span></a>

<?php if ($config['use_print']): ?>
<?php if ($config['use_print_chromakeying']): ?>
<a class="btn btn--flex" id="print-btn" href="#"><i class="fa fa-print"></i> <span data-i18n="print"></span></a>
<?php endif; ?>

Expand Down
21 changes: 14 additions & 7 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@
$config['show_error_messages'] = true;
$config['auto_reload_on_error'] = true;
$config['pictureRotation'] = '0';
$config['use_print'] = false;
$config['use_qr'] = true;
$config['use_download'] = true;
$config['use_slideshow'] = true;
$config['print_qrcode'] = false;
$config['print_frame'] = false;
$config['print_frame_path'] = '../resources/img/frames/frame.png';
$config['crop_onprint'] = false;
$config['crop_width'] = '1000';
$config['crop_height'] = '500';
$config['use_mail'] = false; // mail data needs to be configured
$config['show_fork'] = true;
$config['previewFromCam'] = false; // experimental see https://github.com/andreknieriem/photobooth/pull/30
Expand Down Expand Up @@ -69,6 +62,7 @@
// use for example https://keycode.info to get the key code
$config['photo_key'] = null;
$config['collage_key'] = null;
$config['print_key'] = null;

// LANGUAGE
// possible values: de, el, en, es, fr
Expand Down Expand Up @@ -150,6 +144,19 @@
$config['slideshow_randomPicture'] = true;
$config['slideshow_use_thumbs'] = false;

// PRINT
$config['use_print_result'] = false;
$config['use_print_gallery'] = false;
$config['use_print_chromakeying'] = false;
$config['auto_print'] = false;
$config['auto_print_delay'] = '1000';
$config['printing_time'] = '5000';
$config['print_qrcode'] = false;
$config['print_frame'] = false;
$config['print_frame_path'] = '../resources/img/frames/frame.png';
$config['crop_onprint'] = false;
$config['crop_width'] = '1000';
$config['crop_height'] = '500';
// TEXT ON PRINT
$config['is_textonprint'] = false;
$config['textonprint']['line1'] = 'line 1';
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<a href="#" class="btn mailbtn"><i class="fa fa-envelope"></i> <span data-i18n="mail"></span></a>
<?php endif; ?>

<?php if ($config['use_print']): ?>
<?php if ($config['use_print_result']): ?>
<a href="#" class="btn printbtn"><i class="fa fa-print"></i> <span data-i18n="print"></span></a>
<?php endif; ?>

Expand Down
51 changes: 46 additions & 5 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@
'placeholder' => '0644',
'value' => $config['picture_permissions']
],
'use_print' => [
'type' => 'checkbox',
'name' => 'use_print',
'value' => $config['use_print']
],
'use_qr' => [
'type' => 'checkbox',
'name' => 'use_qr',
Expand Down Expand Up @@ -601,6 +596,52 @@
]
],
'print' => [
'use_print_result' => [
'type' => 'checkbox',
'name' => 'use_print_result',
'value' => $config['use_print_result']
],
'use_print_gallery' => [
'type' => 'checkbox',
'name' => 'use_print_gallery',
'value' => $config['use_print_gallery']
],
'use_print_chromakeying' => [
'type' => 'checkbox',
'name' => 'use_print_chromakeying',
'value' => $config['use_print_chromakeying']
],
'auto_print' => [
'type' => 'checkbox',
'name' => 'auto_print',
'value' => $config['auto_print']
],
'auto_print_delay' => [
'type' => 'range',
'placeholder' => $defaultConfig['auto_print_delay'],
'name' => 'auto_print_delay',
'value' => $config['auto_print_delay'],
'range_min' => 250,
'range_max' => 10000,
'range_step' => 250,
'unit' => 'milliseconds'
],
'printing_time' => [
'type' => 'range',
'placeholder' => $defaultConfig['printing_time'],
'name' => 'printing_time',
'value' => $config['printing_time'],
'range_min' => 250,
'range_max' => 20000,
'range_step' => 250,
'unit' => 'milliseconds'
],
'print_key' => [
'type' => 'input',
'name' => 'print_key',
'placeholder' => '',
'value' => $config['print_key']
],
'print_qrcode' => [
'type' => 'checkbox',
'name' => 'print_qrcode',
Expand Down
2 changes: 0 additions & 2 deletions resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@
"manual_use_download": "Wenn diese Option aktiviert ist, ist für jedes Bild in der Galerie eine Download-Schaltfläche sichtbar.",
"manual_use_filter": "Wenn diese Option aktiviert ist, kann der Benutzer nach dem Aufnehmen eines Bildes einen Bildfilter auswählen.",
"manual_use_mail": "Wenn diese Option aktiviert ist, ist für jedes Bild in der Galerie eine E-Mail-Schaltfläche sichtbar. Abhängig von Ihren Einstellungen können Sie Bilder direkt per E-Mail senden oder die eingegebene E-Mail-Adresse in einer Datenbank sammeln.",
"manual_use_print": "Wenn diese Option aktiviert ist, wird eine Druckschaltfläche auf dem Ergebnisbildschirm, der Galerie und der Chromakeying-Seite angezeigt.",
"manual_use_qr": "Wenn diese Option aktiviert ist, wird eine QR-Schaltfläche auf dem Ergebnisbildschirm und in der Galerie angezeigt. Der Benutzer kann beim Scannen des QR-Codes ein Bild herunterladen. Wenn Sie über \"localhost\", \"127.0.0.1\" auf Photobooth zugreifen oder Photobooth in einem Unterordner installiert haben, definieren Sie bitte die IP-Adresse des Photobooth-Webservers, damit der QR-Code funktioniert. <p>Beispiel, wenn auf Photobooth direkt zugegriffen werden kann: <code>192.168.0.50</code>.</p> <p>Beispiel, wenn Photobooth in einem Unterordner installiert ist: <code>192.168.0.50/photobooth</code>.</p>",
"manual_use_slideshow": "Wenn diese Option aktiviert ist, wird in der Galerie eine Diashow-Schaltfläche angezeigt, mit der Sie eine Diashow starten / stoppen können.",
"manual_use_thumbs": "Wenn diese Option aktiviert ist, werden Miniaturansichten für die Diashow verwendet. Dadurch wird die Leistung leicht verbessert.",
Expand Down Expand Up @@ -349,7 +348,6 @@
"use_download": "Download aktivieren",
"use_filter": "Bildfilter erlauben",
"use_mail": "E-Mail aktivieren",
"use_print": "Drucken aktivieren",
"use_qr": "QR-Code aktivieren",
"use_slideshow": "Diashow in Galerie erlauben",
"use_thumbs": "Thumbnails für die Diashow verwenden",
Expand Down
1 change: 0 additions & 1 deletion resources/lang/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
"use_download": "Επιτρέψτε τη λήψη",
"use_filter": "Αφήστε φίλτρα εικόνας",
"use_mail": "E-Mail Ενεργοποίηση",
"use_print": "Ενεργοποίηση εκτύπωσης",
"use_qr": "Ενεργοποιήστε τον κωδικό QR",
"user_interface": "διεπαφή χρήστη",
"user_interface_background_admin": "Διαδρομή εικόνας φόντου διαχειριστή",
Expand Down
16 changes: 14 additions & 2 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"admin_panel": "Admin panel",
"allow_delete": "Allow deletion of the image",
"allow_delete_from_gallery": "Allow deletion of images from gallery",
"auto_print": "Print picture immediately after taken",
"auto_reload": "Photobooth reloads automatically...",
"auto_reload_on_error": "Automatically reload Photobooth on error",
"available_version": "Available version",
Expand Down Expand Up @@ -112,6 +113,7 @@
"mail_username": "Username of the e-mail account",
"manual_allow_delete": "If enabled pictures can be deleted on result page directly after they have been taken.",
"manual_allow_delete_from_gallery": "If enabled pictures can be deleted from the gallery at any time.",
"manual_auto_print": "If enabled, the picture will immediately printed after it was taken.",
"manual_auto_reload_on_error": "If an error occurs while taking a picture, Photobooth will reload automatically after 5 seconds.",
"manual_chroma_keying": "If enabled, chromakeying can be accessed from gallery for your pictures.",
"manual_commands_exiftool_cmd": "EXIFtool command line which is executed after taking a picture if \"Preserve EXIF data\" is enabled.",
Expand Down Expand Up @@ -192,6 +194,7 @@
"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_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.",
"manual_print_font_path": "Enter the path to the font used to print text onto your image.",
Expand All @@ -204,6 +207,8 @@
"manual_print_linespace": "Enter used linespace while printing text on your picture.",
"manual_print_locationx": "X-Coordinates of the text while printing text on your picture.",
"manual_print_locationy": "Y-Coordinates of the text while printing text on your picture.",
"manual_print_print_key": "Specify the key id to use that key to print 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_print_printing_time": "Enter in milliseconds, how long \"Started printing! Please wait....\" is displayed after a print job has started.",
"manual_print_qrcode": "If enabled, a QR-Code is printed onto the right side of the picture while printing.",
"manual_print_rotation": "Enter a value which is used as degrees a picture gets rotated at print.",
"manual_protect_admin": "If enabled, admin panel can only be accessed if a username and password is entered.",
Expand Down Expand Up @@ -247,7 +252,9 @@
"manual_use_download": "If enabled, a download button is visible on each picture inside the gallery.",
"manual_use_filter": "If enabled, user can choose a imagefiler after taking a picture.",
"manual_use_mail": "If enabled, a email button is visible on each picture inside the gallery. Depending on your setup you can send pictures via email directly or collect entered email address inside a database.",
"manual_use_print": "If enabled, a print button is visible on result screen, gallery and chromakeying page.",
"manual_use_print_chromakeying": "If enabled, a print button is visible on chromakeying page.",
"manual_use_print_gallery": "If enabled, a print button is visible inside the gallery.",
"manual_use_print_result": "If enabled, a print button is visible on result screen.",
"manual_use_qr": "If enabled, a QR-Button is visible on the result screen and inside gallery. User can download a picture while scanning the QR-Code. If you're accessing Photobooth via \"localhost\", \"127.0.0.1\" or if you have Photobooth installed inside a subfolder, please define IP address of the Photobooth web server to make the QR-Code working. <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_use_slideshow": "If enabled, a slideshow button is visible inside the gallery to start/stop a slideshow.",
"manual_use_thumbs": "If enabled, thumbnails are used for standalone gallery. This will improve the performance slightly.",
Expand All @@ -270,6 +277,7 @@
"previewFromCam": "See preview by device cam",
"previewFromIPCam": "Preview from URL",
"print": "Print",
"print_auto_print_delay": "Delay automatic printing of the image",
"print_crop_height": "New height at print (px)",
"print_crop_width": "New width at print (px)",
"print_font_path": "Font",
Expand All @@ -282,6 +290,8 @@
"print_linespace": "Line spacing",
"print_locationx": "X Coordinate",
"print_locationy": "Y Coordinate",
"print_print_key": "Key code which triggers printing",
"print_printing_time": "Printing time",
"print_qrcode": "QR-Code on the picture while printing",
"print_rotation": "Text rotation",
"printing": "Started printing! Please wait...",
Expand Down Expand Up @@ -353,7 +363,9 @@
"use_download": "Allow downloads",
"use_filter": "Allow image filter",
"use_mail": "Use E-Mail",
"use_print": "Use Print",
"use_print_chromakeying": "Allow printing from chromakeying",
"use_print_gallery": "Allow printing from gallery",
"use_print_result": "Allow printing from result page",
"use_qr": "Use QR Codes",
"use_slideshow": "Allow slideshow in gallery",
"use_thumbs": "Use thumbnails for slideshow",
Expand Down
2 changes: 0 additions & 2 deletions resources/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
"manual_use_download": "Si está activado, un botón de descarga es visible en cada imagen dentro de la galería.",
"manual_use_filter": "Si está habilitado, el usuario puede elegir un imagefiler después de tomar una foto.",
"manual_use_mail": "Si está habilitado, un botón de correo electrónico es visible en cada imagen dentro de la galería. Dependiendo de su configuración puede enviar imágenes por correo electrónico directamente o recopilar la dirección de correo electrónico introducida dentro de una base de datos.",
"manual_use_print": "Si está activado, un botón de impresión es visible en la pantalla de resultados, la galería y la página de cromakey.",
"manual_use_qr": "Si está activado, un botón QR es visible en la pantalla de resultados y dentro de la galería. El usuario puede descargar una imagen mientras escanea el código QR. Si está accediendo a Photobooth a través de \"localhost\", \"127.0.0.1\" o si tiene Photobooth instalado dentro de una subcarpeta, defina la dirección IP del servidor web Photobooth para que el código QR funcione. <p>Por ejemplo, si Photobooth se puede acceder directamente: <code>192.168.0.50</code>.</p><p>Por ejemplo, si Photobooth está instalado dentro de una subcarpeta: <code>192.168.0.50/photobooth</code>.</p>",
"manual_use_thumbs": "Si está habilitada, las miniaturas se utilizan para la galería independiente. Esto mejorará ligeramente el rendimiento.",
"manual_user_interface_background_admin": "Estilo CSS para fondo en el panel de administración.",
Expand Down Expand Up @@ -287,7 +286,6 @@
"use_download": "Permitir descargas",
"use_filter": "Autorice el tratamiento de imagen",
"use_mail": "Utilizar el correo electrónico",
"use_print": "Utilizar la impresion",
"use_qr": "Utilizar los códigos QR",
"use_thumbs": "Usar miniaturas para la presentación de diapositivas",
"user_interface": "Interfaz de usuario",
Expand Down
1 change: 0 additions & 1 deletion resources/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
"use_download": "Autoriser les téléchargements",
"use_filter": "Autorisez le filtre d'image",
"use_mail": "Utiliser le courrier électronique",
"use_print": "Utiliser l'impression",
"use_qr": "Utiliser le QR code",
"user_interface": "Interface utilisateur",
"user_interface_background_admin": "Chemin de l'image d'arrière-plan du panneau d'administration",
Expand Down
92 changes: 57 additions & 35 deletions src/js/chromakeying.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let mainImage;
let mainImageWidth;
let mainImageHeight;
let backgroundImage;
let isPrinting = false;

function greenToTransparency(imageIn, imageOut) {
for (let y = 0; y < imageIn.getHeight(); y++) {
Expand Down Expand Up @@ -132,47 +133,58 @@ function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) {
function printImage(filename, cb) {
const errormsg = i18n('error');

setTimeout(function () {
$.ajax({
method: 'GET',
url: 'api/print.php',
data: {
filename: filename
},
success: (data) => {
console.log('Picture processed: ', data);

if (data.error) {
console.log('An error occurred: ', data.error);
if (isPrinting) {
console.log('Printing already: ' + isPrinting);
} else {
isPrinting = true;
setTimeout(function () {
$.ajax({
method: 'GET',
url: 'api/print.php',
data: {
filename: filename
},
success: (data) => {
console.log('Picture processed: ', data);

if (data.error) {
console.log('An error occurred: ', data.error);
$('#print_mesg').empty();
$('#print_mesg').html(
'<div class="modal__body"><span style="color:red">' + data.error + '</span></div>'
);
}

setTimeout(function () {
$('#print_mesg').removeClass('modal--show');
if (data.error) {
$('#print_mesg').empty();
$('#print_mesg').html(
'<div class="modal__body"><span>' + i18n('printing') + '</span></div>'
);
}
cb();
isPrinting = false;
}, config.printing_time);
},
error: (jqXHR, textStatus) => {
console.log('An error occurred: ', textStatus);
$('#print_mesg').empty();
$('#print_mesg').html(
'<div class="modal__body"><span style="color:red">' + data.error + '</span></div>'
'<div class="modal__body"><span style="color:red">' + errormsg + '</span></div>'
);
}

setTimeout(function () {
$('#print_mesg').removeClass('modal--show');
if (data.error) {
setTimeout(function () {
$('#print_mesg').removeClass('modal--show');
$('#print_mesg').empty();
$('#print_mesg').html('<div class="modal__body"><span>' + i18n('printing') + '</span></div>');
}
cb();
}, 5000);
},
error: (jqXHR, textStatus) => {
console.log('An error occurred: ', textStatus);
$('#print_mesg').empty();
$('#print_mesg').html('<div class="modal__body"><span style="color:red">' + errormsg + '</span></div>');

setTimeout(function () {
$('#print_mesg').removeClass('modal--show');
$('#print_mesg').empty();
$('#print_mesg').html('<div class="modal__body"><span>' + i18n('printing') + '</span></div>');
cb();
}, 5000);
}
});
}, 1000);
cb();
isPrinting = false;
}, 5000);
}
});
}, 1000);
}
}

function saveImage(cb) {
Expand Down Expand Up @@ -234,6 +246,16 @@ function closeHandler(ev) {
}
}

$(document).on('keyup', function (ev) {
if (config.use_print_chromakeying && config.print_key && parseInt(config.print_key, 10) === ev.keyCode) {
if (isPrinting) {
console.log('Printing already in progress!');
} else {
$('#print-btn').trigger('click');
}
}
});

$(document).ready(function () {
$('#save-btn').on('click', saveImageHandler);
$('#print-btn').on('click', printImageHandler);
Expand Down
Loading