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

Commit b7abc80

Browse files
committed
WIP: allow to keep single images on collage
Change-Id: I312ca934d69cda3521facc361a88fc3529abb2ce
1 parent 842df45 commit b7abc80

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

api/applyEffects.php

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,57 @@
9393
}
9494
}
9595

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

9999
for ($i = 0; $i < $config['collage']['limit']; $i++) {
100-
$collageSrcImagePaths[] = $collageBasename . '-' . $i . '.jpg';
100+
$filename = $collageBasename . '-' . $i . '.jpg';
101+
$collageSrcImagePaths[] = $config['foldersAbs']['tmp'] . DIRECTORY_SEPARATOR . $filename;
102+
$collageSrcImagePath = $config['foldersAbs']['tmp'] . DIRECTORY_SEPARATOR . $filename;
103+
104+
// Collage single images
105+
if ($config['collage']['show_all']) {
106+
$filename_single_photo = $config['foldersAbs']['images'] . DIRECTORY_SEPARATOR . $filename;
107+
$filename_single_thumb = $config['foldersAbs']['thumbs'] . DIRECTORY_SEPARATOR . $filename;
108+
$imageResource = imagecreatefromjpeg($collageSrcImagePath);
109+
110+
// image scale, create thumbnail
111+
$thumbResource = resizeImage($collageSrcImagePath, $thumb_size, $thumb_size);
112+
113+
imagejpeg($thumbResource, $filename_single_thumb, $config['jpeg_quality']['thumb']);
114+
imagedestroy($thumbResource);
115+
116+
if ($imageModified || ($config['jpeg_quality']['image'] >= 0 && $config['jpeg_quality']['image'] < 100)) {
117+
imagejpeg($imageResource, $filename_single_photo, $config['jpeg_quality']['image']);
118+
// preserve jpeg meta data
119+
if ($config['picture']['preserve_exif_data'] && $config['exiftool']['cmd']) {
120+
$cmd = sprintf($config['exiftool']['cmd'], $collageSrcImagePath, $filename_single_photo);
121+
exec($cmd, $output, $returnValue);
122+
if ($returnValue) {
123+
die(
124+
json_encode([
125+
'error' => 'exiftool returned with an error code',
126+
'cmd' => $cmd,
127+
'returnValue' => $returnValue,
128+
'output' => $output,
129+
])
130+
);
131+
}
132+
}
133+
} else {
134+
copy($collageSrcImagePath, $filename_single_photo);
135+
}
136+
137+
imagedestroy($imageResource);
138+
139+
// insert into database
140+
if ($config['database']['enabled']) {
141+
appendImageToDB($filename);
142+
}
143+
144+
// Change permissions
145+
chmod($filename_single_photo, octdec($picture_permissions));
146+
}
101147
}
102148

103149
if (!createCollage($collageSrcImagePaths, $filename_tmp)) {

config/config.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
$config['collage']['continuous_time'] = '5';
9393
// possible layout values: '2x2', '2x2-2', '2x4', '2x4-2', '1+3', '1+2'
9494
$config['collage']['layout'] = '2x2-2';
95+
$config['collage']['show_all'] = true;
9596
// specify key id (e.g. 13 is the enter key) to use that key to take a collage (collage key)
9697
// use for example https://keycode.info to get the key code
9798
$config['collage']['key'] = null;

lib/configsetup.inc.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,12 @@
591591
],
592592
'value' => $config['collage']['layout'],
593593
],
594+
'collage_show_all' => [
595+
'view' => 'basic',
596+
'type' => 'checkbox',
597+
'name' => 'collage[show_all]',
598+
'value' => $config['collage']['show_all'],
599+
],
594600
'collage_key' => [
595601
'view' => 'expert',
596602
'type' => 'input',

0 commit comments

Comments
 (0)