From ab67bd8b0d6b2c86af30afe6bb66d85b2829cf54 Mon Sep 17 00:00:00 2001 From: Kai Haupt Date: Fri, 18 Sep 2020 13:00:29 +0200 Subject: [PATCH] Added a third collage layout Change-Id: I666532f8d9ddbe69356d3935b3bbe4d86ab6ef7b --- lib/collage.php | 51 +++++++++++++++++++++++++++++++++++++++++ lib/configsetup.inc.php | 3 ++- resources/lang/en.json | 4 ++-- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lib/collage.php b/lib/collage.php index a544978ef..ccb0eb337 100644 --- a/lib/collage.php +++ b/lib/collage.php @@ -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 diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index d4d5ea5b7..3c9addf35 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -238,7 +238,8 @@ 'placeholder' => $defaultConfig['collage_layout'], 'options' => [ '2x2' => '2x2', - '2x4' => '2x4' + '2x4' => '2x4', + '2x4BI' => '2x4 + background image' ], 'value' => $config['collage_layout'] ], diff --git a/resources/lang/en.json b/resources/lang/en.json index 1289cf2b3..f49bcc639 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -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:", @@ -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 https://keycode.info to find out the key id.", "manual_general_collage_layout": "Choose between 2x2 and 2x4 pictures collage layout.",