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

Commit

Permalink
Added a third collage layout
Browse files Browse the repository at this point in the history
Change-Id: I666532f8d9ddbe69356d3935b3bbe4d86ab6ef7b
  • Loading branch information
KH404 authored and andi34 committed Sep 18, 2020
1 parent 960eb94 commit ab67bd8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
51 changes: 51 additions & 0 deletions lib/collage.php
Expand Up @@ -37,6 +37,57 @@ function createCollage($srcImagePaths, $destImagePath, $takeFrame, $framePath, $
imagedestroy($my_collage);
break;
case '2x4':
$degrees = 90;

list($width_before, $height_before) = getimagesize($srcImagePaths[0]);

$my_collage_width = $width_before;
$my_collage_height = $height_before;

$my_collage = imagecreatetruecolor($my_collage_width,$my_collage_height);
$background = imagecolorallocate($my_collage, 240, 240, 240);
imagefill($my_collage,0,0,$background);

$images_rotated = array();

for ($i = 0; $i < 4; $i++) {
$img_tmp = imagecreatefromjpeg($srcImagePaths[$i]);

if ($takeFrame) {
$frame = imagecreatefrompng($framePath);
$frame = resizePngImage($frame, imagesx($img_tmp), imagesy($img_tmp));
$x = (imagesx($img_tmp)/2) - (imagesx($frame)/2);
$y = (imagesy($img_tmp)/2) - (imagesy($frame)/2);
imagecopy($img_tmp, $frame, $x, $y, 0, 0, imagesx($frame), imagesy($frame));
}

$img_rotate_tmp = imagerotate($img_tmp, $degrees, 0);
$images_rotated[] = resizeImage($img_rotate_tmp, $height_before/3.3, $width_before/3.5);
}

$new_width = imagesx($images_rotated[0]);
$new_height = imagesy($images_rotated[0]);

$height_offset = ((($my_collage_height/2)-$new_height)/2);
$width_offset = (($my_collage_width-($new_width*4))/5);

$positions_top = [[$width_offset, $height_offset], [($width_offset*2+$new_width), $height_offset], [($width_offset*3+2*$new_width), $height_offset], [($width_offset*4+3*$new_width), $height_offset]];
$positions_bottom = [[$width_offset, ($new_height+(3*$height_offset))], [($width_offset*2+$new_width), ($new_height+(3*$height_offset))], [($width_offset*3+2*$new_width), ($new_height+(3*$height_offset))], [($width_offset*4+3*$new_width), ($new_height+(3*$height_offset))]];

for ($i = 0; $i < 4; $i++) {
$position_top = $positions_top[$i];
$position_bottom = $positions_bottom[$i];

imagecopy( $my_collage, $images_rotated[$i],$position_top[0],$position_top[1],0,0,$new_width,$new_height);
imagecopy( $my_collage, $images_rotated[$i],$position_bottom[0],$position_bottom[1],0,0,$new_width,$new_height);
}

imagescale($my_collage, $width_before, $height_before);

imagejpeg($my_collage, $destImagePath);
imagedestroy($my_collage);
break;
case '2x4BI':
$widthNew=321;
$heightNew=482;
$PositionsX = [63, 423, 785, 1146]; //X offset in Pixel
Expand Down
3 changes: 2 additions & 1 deletion lib/configsetup.inc.php
Expand Up @@ -238,7 +238,8 @@
'placeholder' => $defaultConfig['collage_layout'],
'options' => [
'2x2' => '2x2',
'2x4' => '2x4'
'2x4' => '2x4',
'2x4BI' => '2x4 + background image'
],
'value' => $config['collage_layout']
],
Expand Down
4 changes: 2 additions & 2 deletions resources/lang/en.json
Expand Up @@ -57,7 +57,7 @@
"general_camera_mode": "Camera facing mode",
"general_cheese_time": "Cheeeeeeeese!-Timer:",
"general_cntdwn_time": "Countdown timer:",
"general_collage_background": "Path to the background for 2x4 collage",
"general_collage_background": "Path to the background for \"2x4 + background image\" collage",
"general_collage_cntdwn_time": "Collage-countdown timer:",
"general_collage_key": "Key code which triggers a collage",
"general_collage_layout": "Choose collage layout:",
Expand Down Expand Up @@ -146,7 +146,7 @@
"manual_general_camera_mode": "Choose between front- or back facing camera mode of your device cam.",
"manual_general_cheese_time": "Set a time to display \"Cheeeeeeeese!\" after the countdown.",
"manual_general_cntdwn_time": "Set your countdown time.",
"manual_general_collage_background": "Enter the path of the background which is applied to your collage on 2x4 collage layout.",
"manual_general_collage_background": "Enter the path of the background which is applied to your collage on \"2x4 + background image\" collage layout.",
"manual_general_collage_cntdwn_time": "Set your countdown time between pictures while taking a collage.",
"manual_general_collage_key": "Specify the key id to use that key to take a collage (e.g. 13 is the enter key). For example use <a href=\"https://keycode.info\" target=\"_blank\">https://keycode.info</a> to find out the key id.",
"manual_general_collage_layout": "Choose between 2x2 and 2x4 pictures collage layout.",
Expand Down

0 comments on commit ab67bd8

Please sign in to comment.