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

Commit

Permalink
WIP: allow to keep single images on collage
Browse files Browse the repository at this point in the history
Change-Id: I312ca934d69cda3521facc361a88fc3529abb2ce
  • Loading branch information
andi34 committed Jul 7, 2021
1 parent 842df45 commit b7abc80
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
50 changes: 48 additions & 2 deletions api/applyEffects.php
Expand Up @@ -93,11 +93,57 @@
}
}

$collageBasename = substr($filename_tmp, 0, -4);
$collageBasename = substr($file, 0, -4);
$collageSrcImagePaths = [];

for ($i = 0; $i < $config['collage']['limit']; $i++) {
$collageSrcImagePaths[] = $collageBasename . '-' . $i . '.jpg';
$filename = $collageBasename . '-' . $i . '.jpg';
$collageSrcImagePaths[] = $config['foldersAbs']['tmp'] . DIRECTORY_SEPARATOR . $filename;
$collageSrcImagePath = $config['foldersAbs']['tmp'] . DIRECTORY_SEPARATOR . $filename;

// Collage single images
if ($config['collage']['show_all']) {
$filename_single_photo = $config['foldersAbs']['images'] . DIRECTORY_SEPARATOR . $filename;
$filename_single_thumb = $config['foldersAbs']['thumbs'] . DIRECTORY_SEPARATOR . $filename;
$imageResource = imagecreatefromjpeg($collageSrcImagePath);

// image scale, create thumbnail
$thumbResource = resizeImage($collageSrcImagePath, $thumb_size, $thumb_size);

imagejpeg($thumbResource, $filename_single_thumb, $config['jpeg_quality']['thumb']);
imagedestroy($thumbResource);

if ($imageModified || ($config['jpeg_quality']['image'] >= 0 && $config['jpeg_quality']['image'] < 100)) {
imagejpeg($imageResource, $filename_single_photo, $config['jpeg_quality']['image']);
// preserve jpeg meta data
if ($config['picture']['preserve_exif_data'] && $config['exiftool']['cmd']) {
$cmd = sprintf($config['exiftool']['cmd'], $collageSrcImagePath, $filename_single_photo);
exec($cmd, $output, $returnValue);
if ($returnValue) {
die(
json_encode([
'error' => 'exiftool returned with an error code',
'cmd' => $cmd,
'returnValue' => $returnValue,
'output' => $output,
])
);
}
}
} else {
copy($collageSrcImagePath, $filename_single_photo);
}

imagedestroy($imageResource);

// insert into database
if ($config['database']['enabled']) {
appendImageToDB($filename);
}

// Change permissions
chmod($filename_single_photo, octdec($picture_permissions));
}
}

if (!createCollage($collageSrcImagePaths, $filename_tmp)) {
Expand Down
1 change: 1 addition & 0 deletions config/config.inc.php
Expand Up @@ -92,6 +92,7 @@
$config['collage']['continuous_time'] = '5';
// possible layout values: '2x2', '2x2-2', '2x4', '2x4-2', '1+3', '1+2'
$config['collage']['layout'] = '2x2-2';
$config['collage']['show_all'] = true;
// specify key id (e.g. 13 is the enter key) to use that key to take a collage (collage key)
// use for example https://keycode.info to get the key code
$config['collage']['key'] = null;
Expand Down
6 changes: 6 additions & 0 deletions lib/configsetup.inc.php
Expand Up @@ -591,6 +591,12 @@
],
'value' => $config['collage']['layout'],
],
'collage_show_all' => [
'view' => 'basic',
'type' => 'checkbox',
'name' => 'collage[show_all]',
'value' => $config['collage']['show_all'],
],
'collage_key' => [
'view' => 'expert',
'type' => 'input',
Expand Down

0 comments on commit b7abc80

Please sign in to comment.