Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
uldisrudzitis committed May 29, 2024
1 parent 90bb64d commit 2818f90
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions _api_app/app/Shared/ImageHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,17 @@ public static function crop($file, $x, $y, $w, $h)
$info = getimagesize($file);

switch ($info[2]) {
case IMAGETYPE_GIF:$image = imagecreatefromgif($file);
case IMAGETYPE_GIF:
$image = imagecreatefromgif($file);
break;
case IMAGETYPE_JPEG:$image = imagecreatefromjpeg($file);
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($file);
break;
case IMAGETYPE_PNG:$image = imagecreatefrompng($file);
case IMAGETYPE_PNG:
$image = imagecreatefrompng($file);
break;
default:return false;
default:
return false;
}

//in case of incorrect params
Expand Down Expand Up @@ -259,13 +263,17 @@ public static function crop($file, $x, $y, $w, $h)
imagecopy($image_resized, $image, 0, 0, $x, $y, $w, $h);

switch ($info[2]) {
case IMAGETYPE_GIF:imagegif($image_resized, $file);
case IMAGETYPE_GIF:
imagegif($image_resized, $file);
break;
case IMAGETYPE_JPEG:imagejpeg($image_resized, $file, 97);
case IMAGETYPE_JPEG:
imagejpeg($image_resized, $file, 97);
break;
case IMAGETYPE_PNG:imagepng($image_resized, $file);
case IMAGETYPE_PNG:
imagepng($image_resized, $file);
break;
default:return false;
default:
return false;
}
}

Expand Down Expand Up @@ -306,8 +314,8 @@ private static function createThumbnail($imagePath, $thumbPath, $thumbWidth, $th

$canMakeThumb = function_exists('imagejpeg') &&
(($imageInfo[2] == IMAGETYPE_GIF && function_exists('imagecreatefromgif')) ||
($imageInfo[2] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) ||
($imageInfo[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')));
($imageInfo[2] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) ||
($imageInfo[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')));

if ($canMakeThumb) {
if ($thumbWidth && !$thumbHeight) {
Expand Down Expand Up @@ -401,13 +409,17 @@ private static function resize(

// Loading image to memory according to type
switch ($info[2]) {
case IMAGETYPE_GIF:$image = imagecreatefromgif($file);
case IMAGETYPE_GIF:
$image = imagecreatefromgif($file);
break;
case IMAGETYPE_JPEG:$image = imagecreatefromjpeg($file);
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($file);
break;
case IMAGETYPE_PNG:$image = imagecreatefrompng($file);
case IMAGETYPE_PNG:
$image = imagecreatefrompng($file);
break;
default:return false;
default:
return false;
}

// Don't resize animated gifs
Expand Down

0 comments on commit 2818f90

Please sign in to comment.