diff --git a/chromakeying.php b/chromakeying.php index 7ff431cda..ecbb19f33 100644 --- a/chromakeying.php +++ b/chromakeying.php @@ -71,7 +71,7 @@
- + diff --git a/config/config.inc.php b/config/config.inc.php index dac810f72..b1e6da292 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -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 @@ -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 @@ -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'; diff --git a/index.php b/index.php index ca7cb7598..233292268 100644 --- a/index.php +++ b/index.php @@ -162,7 +162,7 @@ - + diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index 0549e0bfb..5417c1d7f 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -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', @@ -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', diff --git a/resources/lang/de.json b/resources/lang/de.json index 6f9d22b02..409ad7a18 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -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.

Beispiel, wenn auf Photobooth direkt zugegriffen werden kann: 192.168.0.50.

Beispiel, wenn Photobooth in einem Unterordner installiert ist: 192.168.0.50/photobooth.

", "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.", @@ -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", diff --git a/resources/lang/el.json b/resources/lang/el.json index 1b708bffe..fb17d4eef 100644 --- a/resources/lang/el.json +++ b/resources/lang/el.json @@ -119,7 +119,6 @@ "use_download": "Επιτρέψτε τη λήψη", "use_filter": "Αφήστε φίλτρα εικόνας", "use_mail": "E-Mail Ενεργοποίηση", - "use_print": "Ενεργοποίηση εκτύπωσης", "use_qr": "Ενεργοποιήστε τον κωδικό QR", "user_interface": "διεπαφή χρήστη", "user_interface_background_admin": "Διαδρομή εικόνας φόντου διαχειριστή", diff --git a/resources/lang/en.json b/resources/lang/en.json index 8f5d8a7df..f05ca0f1f 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -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", @@ -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.", @@ -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 here.", "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.", @@ -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 https://keycode.info 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.", @@ -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.

Example if Photobooth can be accessed directly: 192.168.0.50.

Example if Photobooth is installed inside a subfolder: 192.168.0.50/photobooth.

", "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.", @@ -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", @@ -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...", @@ -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", diff --git a/resources/lang/es.json b/resources/lang/es.json index 5784a6a0b..999b8efe5 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -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.

Por ejemplo, si Photobooth se puede acceder directamente: 192.168.0.50.

Por ejemplo, si Photobooth está instalado dentro de una subcarpeta: 192.168.0.50/photobooth.

", "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.", @@ -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", diff --git a/resources/lang/fr.json b/resources/lang/fr.json index f739eb5b0..aaf1edac1 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -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", diff --git a/src/js/chromakeying.js b/src/js/chromakeying.js index 05dc71c53..8633d01c5 100644 --- a/src/js/chromakeying.js +++ b/src/js/chromakeying.js @@ -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++) { @@ -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( + '' + ); + } + + setTimeout(function () { + $('#print_mesg').removeClass('modal--show'); + if (data.error) { + $('#print_mesg').empty(); + $('#print_mesg').html( + '' + ); + } + cb(); + isPrinting = false; + }, config.printing_time); + }, + error: (jqXHR, textStatus) => { + console.log('An error occurred: ', textStatus); $('#print_mesg').empty(); $('#print_mesg').html( - '' + '' ); - } - setTimeout(function () { - $('#print_mesg').removeClass('modal--show'); - if (data.error) { + setTimeout(function () { + $('#print_mesg').removeClass('modal--show'); $('#print_mesg').empty(); $('#print_mesg').html(''); - } - cb(); - }, 5000); - }, - error: (jqXHR, textStatus) => { - console.log('An error occurred: ', textStatus); - $('#print_mesg').empty(); - $('#print_mesg').html(''); - - setTimeout(function () { - $('#print_mesg').removeClass('modal--show'); - $('#print_mesg').empty(); - $('#print_mesg').html(''); - cb(); - }, 5000); - } - }); - }, 1000); + cb(); + isPrinting = false; + }, 5000); + } + }); + }, 1000); + } } function saveImage(cb) { @@ -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); diff --git a/src/js/core.js b/src/js/core.js index 8ad51fa95..98ff92998 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -22,6 +22,7 @@ const photoBooth = (function () { videoSensor = document.querySelector('#video--sensor'); let timeOut, + isPrinting = false, takingPic = false, nextCollageNumber = 0, currentCollageFile = '', @@ -478,6 +479,13 @@ const photoBooth = (function () { }); }); + // If autoprint is activated the picture will immediately printed after taken. + if (config.auto_print) { + setTimeout(function () { + api.printImage(filename); + }, config.auto_print_delay); + } + resultPage .find('.deletebtn') .off('click') @@ -610,54 +618,63 @@ const photoBooth = (function () { }; api.printImage = function (imageSrc, cb) { - modal.open('#print_mesg'); const errormsg = i18n('error'); - setTimeout(function () { - $.ajax({ - method: 'GET', - url: 'api/print.php', - data: { - filename: imageSrc - }, - 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 { + modal.open('#print_mesg'); + isPrinting = true; + setTimeout(function () { + $.ajax({ + method: 'GET', + url: 'api/print.php', + data: { + filename: imageSrc + }, + success: (data) => { + console.log('Picture processed: ', data); + + if (data.error) { + console.log('An error occurred: ', data.error); + $('#print_mesg').empty(); + $('#print_mesg').html( + '' + ); + } + + setTimeout(function () { + modal.close('#print_mesg'); + if (data.error) { + $('#print_mesg').empty(); + $('#print_mesg').html( + '' + ); + } + cb(); + isPrinting = false; + }, config.printing_time); + }, + error: (jqXHR, textStatus) => { + console.log('An error occurred: ', textStatus); $('#print_mesg').empty(); $('#print_mesg').html( - '' + '' ); - } - setTimeout(function () { - modal.close('#print_mesg'); - if (data.error) { + setTimeout(function () { + modal.close('#print_mesg'); $('#print_mesg').empty(); $('#print_mesg').html( '' ); - } - cb(); - }, 5000); - }, - error: (jqXHR, textStatus) => { - console.log('An error occurred: ', textStatus); - $('#print_mesg').empty(); - $('#print_mesg').html( - '' - ); - - setTimeout(function () { - modal.close('#print_mesg'); - $('#print_mesg').empty(); - $('#print_mesg').html(''); - cb(); - }, 5000); - } - }); - }, 1000); + cb(); + isPrinting = false; + }, 5000); + } + }); + }, 1000); + } }; api.deleteImage = function (imageName, cb) { @@ -882,6 +899,15 @@ const photoBooth = (function () { console.log('Taking photo already in progress!'); } } + + if (config.use_print_result && config.print_key && parseInt(config.print_key, 10) === ev.keyCode) { + if (isPrinting) { + console.log('Printing already in progress!'); + } else { + $('.printbtn').trigger('click'); + $('.printbtn').blur(); + } + } }); // clear Timeout to not reset the gallery, if you clicked anywhere diff --git a/src/js/photoinit.js b/src/js/photoinit.js index 9f452dc6d..dd819eb6c 100644 --- a/src/js/photoinit.js +++ b/src/js/photoinit.js @@ -4,7 +4,8 @@ function initPhotoSwipeFromDOM(gallerySelector) { let gallery, ssRunning = false, - ssOnce = false; + ssOnce = false, + isPrinting = false; const ssDelay = config.gallery_pictureTime, ssButtonClass = '.pswp__button--playpause'; @@ -230,11 +231,17 @@ function initPhotoSwipeFromDOM(gallerySelector) { e.preventDefault(); e.stopPropagation(); - const img = gallery.currItem.src.split('\\').pop().split('/').pop(); + if (isPrinting) { + console.log('Printing already in progress!'); + } else { + isPrinting = true; + const img = gallery.currItem.src.split('\\').pop().split('/').pop(); - photoBooth.printImage(img, () => { - gallery.close(); - }); + photoBooth.printImage(img, () => { + gallery.close(); + isPrinting = false; + }); + } }); // Close Gallery while Taking a Picture or Collage @@ -296,4 +303,14 @@ function initPhotoSwipeFromDOM(gallerySelector) { } $(gallerySelector).on('click', onThumbnailClick); + + $(document).on('keyup', function (ev) { + if (config.use_print_gallery && config.print_key && parseInt(config.print_key, 10) === ev.keyCode) { + if (isPrinting) { + console.log('Printing already in progress!'); + } else { + $('.pswp__button--print').trigger('click'); + } + } + }); } diff --git a/template/pswp.template.php b/template/pswp.template.php index 96eb88c0f..fb9e0a940 100644 --- a/template/pswp.template.php +++ b/template/pswp.template.php @@ -33,7 +33,7 @@ - +