Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement #226

Merged
merged 4 commits into from
Feb 28, 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
23 changes: 20 additions & 3 deletions api/applyEffects.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
'error' => 'Could not create collage'
]));
}

if (!$config['keep_images']) {
foreach ($collageSrcImagePaths as $tmp) {
unlink($tmp);
}
}
}

if (!file_exists($filename_tmp)) {
Expand All @@ -43,6 +49,7 @@
}

$imageResource = imagecreatefromjpeg($filename_tmp);
$imageModified = false;

if (!$imageResource) {
die(json_encode([
Expand All @@ -65,12 +72,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') {
Expand All @@ -79,11 +87,11 @@
$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);
}
Expand All @@ -94,7 +102,16 @@
imagejpeg($thumbResource, $filename_thumb, $config['jpeg_quality_thumb']);
imagedestroy($thumbResource);

imagejpeg($imageResource, $filename_photo, $config['jpeg_quality_image']);
if ($imageModified || $config['jpeg_quality_image'] >= 0) {
imagejpeg($imageResource, $filename_photo, $config['jpeg_quality_image']);
} else {
copy($filename_tmp, $filename_photo);
}

if (!$config['keep_images']) {
unlink($filename_tmp);
}

imagedestroy($imageResource);

// insert into database
Expand Down
1 change: 1 addition & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/gr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down