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

Commit

Permalink
lib (collage): some adjustments
Browse files Browse the repository at this point in the history
Change-Id: I03d2ef1a12fe7b0d3094f8cacf4117de1d90e755
  • Loading branch information
andi34 committed Sep 19, 2020
1 parent 21aa072 commit 0bcd6c0
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/collage.php
Expand Up @@ -64,22 +64,22 @@ function createCollage($srcImagePaths, $destImagePath, $takeFrame, $takeFrameAlw
$images_rotated = array();

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

if (!file_exists($srcImagePaths[$i])) {
return false;
}

if ($takeFrame && $takeFrameAlways) {
$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));
$frame = resizePngImage($frame, imagesx($tempSubImage), imagesy($tempSubImage));
$x = (imagesx($tempSubImage)/2) - (imagesx($frame)/2);
$y = (imagesy($tempSubImage)/2) - (imagesy($frame)/2);
imagecopy($tempSubImage, $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);
$tempSubRotated = imagerotate($tempSubImage, $degrees, 0);
$images_rotated[] = resizeImage($tempSubRotated, $height_before/3.3, $width_before/3.5);
}

if ($takeFrame && !$takeFrameAlways) {
Expand Down Expand Up @@ -113,6 +113,7 @@ function createCollage($srcImagePaths, $destImagePath, $takeFrame, $takeFrameAlw
imagedestroy($my_collage);
break;
case '2x4BI':
$degrees = 90;
$widthNew=321;
$heightNew=482;
$PositionsX = [63, 423, 785, 1146]; //X offset in Pixel
Expand All @@ -137,11 +138,11 @@ function createCollage($srcImagePaths, $destImagePath, $takeFrame, $takeFrameAlw
imagecopy($tempSubImage, $frame, $x, $y, 0, 0, imagesx($frame), imagesy($frame));
}

$tempSubRotated = imagerotate($tempSubImage, 90, 0);// Rotate image
$tempSubRotated = imagerotate($tempSubImage, $degrees, 0);// Rotate image
list($width, $height) = getimagesize($srcImagePaths[0]);
imagecopyresized($my_collage, $tempSubRotated, $dX, $dY, 0, 0, $widthNew, $heightNew, $height, $width); // copy image to background
imagedestroy($tempSubImage); // Destroy temporary images
imagedestroy($tempSubRotated); // Destroy temporary images
imagedestroy($tempSubImage); // Destroy temporary images
}
}
if ($takeFrame && !$takeFrameAlways) {
Expand All @@ -151,14 +152,14 @@ function createCollage($srcImagePaths, $destImagePath, $takeFrame, $takeFrameAlw
$y = (imagesy($my_collage)/2) - (imagesy($frame)/2);
imagecopy($my_collage, $frame, $x, $y, 0, 0, $bg_width, $bg_height);
}
imagejpeg($my_collage, $destImagePath); // Transfer immage to destImagePath with returns the image to core
imagejpeg($my_collage, $destImagePath); // Transfer image to destImagePath with returns the image to core
imagedestroy($my_collage); // Destroy the created collage in memory
break;
default:
list($width, $height) = getimagesize($srcImagePaths[0]);

$my_collage = imagecreatetruecolor($width, $height);
imagejpeg($my_collage, $destImagePath); // Transfer immage to destImagePath with returns the image to core
imagejpeg($my_collage, $destImagePath); // Transfer image to destImagePath with returns the image to core
imagedestroy($my_collage); // Destroy the created collage in memory
break;
}
Expand Down

0 comments on commit 0bcd6c0

Please sign in to comment.