From e3678a710470dd0204ac26101419cefcadb69bac Mon Sep 17 00:00:00 2001 From: jacques42 Date: Fri, 7 Feb 2020 23:09:51 +0100 Subject: [PATCH 1/4] Performance improvements Change-Id: I0803e65fb89ec4a11df7a2fceb9e11805c97273b --- api/applyEffects.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/api/applyEffects.php b/api/applyEffects.php index f7cf9adc0..79f1d1971 100644 --- a/api/applyEffects.php +++ b/api/applyEffects.php @@ -43,6 +43,7 @@ } $imageResource = imagecreatefromjpeg($filename_tmp); +$imageModified = false; if (!$imageResource) { die(json_encode([ @@ -65,12 +66,13 @@ // apply filter if ($image_filter) { applyFilter($image_filter, $imageResource); + $imageModified = true; } if ($config['polaroid_effect']) { $polaroid_rotation = $config['polaroid_rotation']; - $imageResource = effectPolaroid($imageResource, $polaroid_rotation, 200, 200, 200); + $imageModified = true; } if ($config['take_frame'] && $_POST['isCollage'] !== 'true') { @@ -79,13 +81,14 @@ $x = (imagesx($imageResource)/2) - (imagesx($frame)/2); $y = (imagesy($imageResource)/2) - (imagesy($frame)/2); imagecopy($imageResource, $frame, $x, $y, 0, 0, imagesx($frame), imagesy($frame)); + $imageModified = true; } if ($config['chroma_keying']) { $chromaCopyResource = resizeImage($imageResource, 1500, 1000); - imagejpeg($chromaCopyResource, $filename_keying, $config['jpeg_quality_chroma']); imagedestroy($chromaCopyResource); + $imageModified = true; } // image scale, create thumbnail @@ -94,7 +97,12 @@ imagejpeg($thumbResource, $filename_thumb, $config['jpeg_quality_thumb']); imagedestroy($thumbResource); -imagejpeg($imageResource, $filename_photo, $config['jpeg_quality_image']); +if ($imageModified || $config['jpeg_quality_image'] != -1) { + imagejpeg($imageResource, $filename_photo, $config['jpeg_quality_image']); +} else { + copy ( $filename_tmp, $filename_photo); +} +unlink ($filename_tmp); imagedestroy($imageResource); // insert into database From ca14c98d2646f8bc35729c38820247678ebfe5b8 Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Mon, 10 Feb 2020 09:10:57 +0100 Subject: [PATCH 2/4] Don't delete tmp images, fix formatting, define imageModified where needed - to do: add an option to delete/keep images in tmp folder Change-Id: I3c14643684a88ef72e2b9acc48db825f749b8604 --- api/applyEffects.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/api/applyEffects.php b/api/applyEffects.php index 79f1d1971..bf8e40e6d 100644 --- a/api/applyEffects.php +++ b/api/applyEffects.php @@ -88,7 +88,6 @@ $chromaCopyResource = resizeImage($imageResource, 1500, 1000); imagejpeg($chromaCopyResource, $filename_keying, $config['jpeg_quality_chroma']); imagedestroy($chromaCopyResource); - $imageModified = true; } // image scale, create thumbnail @@ -97,12 +96,11 @@ imagejpeg($thumbResource, $filename_thumb, $config['jpeg_quality_thumb']); imagedestroy($thumbResource); -if ($imageModified || $config['jpeg_quality_image'] != -1) { +if ($imageModified || $config['jpeg_quality_image'] >= 0) { imagejpeg($imageResource, $filename_photo, $config['jpeg_quality_image']); } else { - copy ( $filename_tmp, $filename_photo); + copy($filename_tmp, $filename_photo); } -unlink ($filename_tmp); imagedestroy($imageResource); // insert into database From 657fc901cb7104422e00e8426280910ba91804e7 Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Mon, 10 Feb 2020 09:30:35 +0100 Subject: [PATCH 3/4] Add option to keep original images in tmp folder Change-Id: I9dabafcd90e3d83fe667d3ddff76d9e17b7479f1 --- api/applyEffects.php | 5 +++++ config/config.inc.php | 1 + lib/configsetup.inc.php | 5 +++++ resources/lang/de.js | 1 + resources/lang/en.js | 1 + resources/lang/es.js | 1 + resources/lang/fr.js | 1 + resources/lang/gr.js | 1 + 8 files changed, 16 insertions(+) diff --git a/api/applyEffects.php b/api/applyEffects.php index bf8e40e6d..72def9b76 100644 --- a/api/applyEffects.php +++ b/api/applyEffects.php @@ -101,6 +101,11 @@ } else { copy($filename_tmp, $filename_photo); } + +if (!$config['keep_images']) { + unlink($filename_tmp); +} + imagedestroy($imageResource); // insert into database diff --git a/config/config.inc.php b/config/config.inc.php index e89d27b10..3935c96eb 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -28,6 +28,7 @@ $config['cntdwn_time'] = '5'; // control countdown timer $config['collage_cntdwn_time'] = '3'; // control countdown timer between collage pictures $config['cheese_time'] = '1000'; // control time for cheeeeese! +$config['keep_images'] = true; $config['use_filter'] = true; $config['default_imagefilter'] = 'plain'; $config['disabled_filters'] = array(); diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index cc06d13f6..055510601 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -33,6 +33,11 @@ 'name' => 'dev', 'value' => $config['dev'] ], + 'keep_images' => [ + 'type' => 'checkbox', + 'name' => 'keep_images', + 'value' => $config['keep_images'] + ], 'show_error_messages' => [ 'type' => 'checkbox', 'name' => 'show_error_messages', diff --git a/resources/lang/de.js b/resources/lang/de.js index c504c456c..ddb940ed2 100644 --- a/resources/lang/de.js +++ b/resources/lang/de.js @@ -90,6 +90,7 @@ const L10N = { 'folders_tmp': 'tmp Ordner', 'folders_keying': 'Keying Ordner', 'folders_data': 'Data Ordner', + 'keep_images': 'Original Bilder im tmp Ordner behalten', 'general_language': 'Sprache', 'send_all_later': 'Checkbox aktivieren um die eingegebene Adresse einer Datei hinzuzufügen (z.B. um später eine Mail mit allen Bildern zu versenden)', 'mail_host': 'E-Mail Host Adresse', diff --git a/resources/lang/en.js b/resources/lang/en.js index a582a559b..9afb1ee20 100644 --- a/resources/lang/en.js +++ b/resources/lang/en.js @@ -90,6 +90,7 @@ const L10N = { 'folders_tmp': 'tmp Folder', 'folders_keying': 'Keying Folder', 'folders_data': 'Data Folder', + 'keep_images': 'Keep original images in tmp folder', 'general_language': 'Language', 'send_all_later': 'Activate checkbox to add the entered address to a file (for example, to send a mail with all pictures later)', 'mail_host': 'E-mail host adress', diff --git a/resources/lang/es.js b/resources/lang/es.js index e435691d5..d763a9b2f 100644 --- a/resources/lang/es.js +++ b/resources/lang/es.js @@ -90,6 +90,7 @@ const L10N = { 'folders_tmp': 'Carpeta búfer', 'folders_keying': 'Carpeta de croma verde', 'folders_data': 'Carpeta de data', + 'keep_images': 'Keep original images in tmp folder', 'general_language': 'Idioma general', 'send_all_later': 'Active la casilla de verificación para añadir el correo electrónico ingresado a un fichero (por ejemplo, para enviar todas las fotos más tarde)', 'mail_host': 'Correo electrónico de anfitrión', diff --git a/resources/lang/fr.js b/resources/lang/fr.js index ed308bbf1..cee0922b3 100644 --- a/resources/lang/fr.js +++ b/resources/lang/fr.js @@ -91,6 +91,7 @@ const L10N = { 'folders_data': 'Dossier data', 'folders_keying': 'Dossier font vert', 'general_language': 'La langue', + 'keep_images': 'Keep original images in tmp folder', 'send_all_later': 'Activez la case à cocher pour ajouter l\'adresse saisie à un fichier (par exemple, pour envoyer un courrier avec toutes les images ultérieurement)', 'mail_host': 'Adresse mail de l\'hôte', 'mail_username': 'Nom d\'utilisateur du compte de messagerie', diff --git a/resources/lang/gr.js b/resources/lang/gr.js index 5a7858342..629753690 100644 --- a/resources/lang/gr.js +++ b/resources/lang/gr.js @@ -90,6 +90,7 @@ const L10N = { 'folders_tmp': 'tmp φάκελο', 'folders_keying': 'Keying αρχείο', 'general_language': 'γλώσσα', + 'keep_images': 'Keep original images in tmp folder', 'send_all_later': 'Ενεργοποιήστε το πλαίσιο ελέγχου για να προσθέσετε την καταχωρημένη διεύθυνση σε ένα αρχείο(π.χ. για να στείλετε ένα μήνυμα αργότερα με όλες τις εικόνες)', 'mail_host': 'E-Mail Διεύθυνση κεντρικού υπολογιστή', 'mail_username': 'Όνομα χρήστη του E-Mail', From d308ba266aa55db99c669a4795c8df419ae0644b Mon Sep 17 00:00:00 2001 From: jacques42 Date: Fri, 14 Feb 2020 23:58:39 +0100 Subject: [PATCH 4/4] image-handling: delete / keep original collage camera files in tmp folder --- api/applyEffects.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/applyEffects.php b/api/applyEffects.php index 72def9b76..369a0230b 100644 --- a/api/applyEffects.php +++ b/api/applyEffects.php @@ -34,6 +34,12 @@ 'error' => 'Could not create collage' ])); } + + if (!$config['keep_images']) { + foreach ($collageSrcImagePaths as $tmp) { + unlink($tmp); + } + } } if (!file_exists($filename_tmp)) {