From ce69f0e4098c67ca966d0f4c56395c55a209b424 Mon Sep 17 00:00:00 2001 From: Rico van Zelst Date: Mon, 25 Dec 2023 23:50:18 +0100 Subject: [PATCH] refactor(helper): update image processing in HelperFunctions.php - Replace the deprecated `Intervention\Image\ImageManagerStatic` with `Intervention\Image\ImageManager`. - Use the `Intervention\Image\Drivers\Gd\Driver` for image manipulation. - Update the code to read and resize images using the new ImageManager instance. - Modify color picking logic to use the updated syntax for accessing RGB values. --- app/Helpers/HelperFunctions.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Helpers/HelperFunctions.php b/app/Helpers/HelperFunctions.php index 2cee892..7db6d3f 100644 --- a/app/Helpers/HelperFunctions.php +++ b/app/Helpers/HelperFunctions.php @@ -1,6 +1,7 @@ read(file_get_contents($imageUrl)); $img->resize(24, 24); @@ -31,9 +34,9 @@ function getAverageColorFromImageUrl($imageUrl): string for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { $color = $img->pickColor($x, $y); - $totalR += $color[0]; - $totalG += $color[1]; - $totalB += $color[2]; + $totalR += $color->red()->toInt(); + $totalG += $color->green()->toInt(); + $totalB += $color->blue()->toInt(); } }