mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
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.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Intervention\Image\ImageManagerStatic as Image;
|
use Intervention\Image\ImageManager;
|
||||||
|
use Intervention\Image\Drivers\Gd\Driver;
|
||||||
|
|
||||||
function getRoleIcon($roleName): string
|
function getRoleIcon($roleName): string
|
||||||
{
|
{
|
||||||
@@ -17,7 +18,9 @@ function getRoleIcon($roleName): string
|
|||||||
|
|
||||||
function getAverageColorFromImageUrl($imageUrl): string
|
function getAverageColorFromImageUrl($imageUrl): string
|
||||||
{
|
{
|
||||||
$img = Image::make($imageUrl);
|
$imgManager = new ImageManager(new Driver());
|
||||||
|
|
||||||
|
$img = $imgManager->read(file_get_contents($imageUrl));
|
||||||
|
|
||||||
$img->resize(24, 24);
|
$img->resize(24, 24);
|
||||||
|
|
||||||
@@ -31,9 +34,9 @@ function getAverageColorFromImageUrl($imageUrl): string
|
|||||||
for ($x = 0; $x < $width; $x++) {
|
for ($x = 0; $x < $width; $x++) {
|
||||||
for ($y = 0; $y < $height; $y++) {
|
for ($y = 0; $y < $height; $y++) {
|
||||||
$color = $img->pickColor($x, $y);
|
$color = $img->pickColor($x, $y);
|
||||||
$totalR += $color[0];
|
$totalR += $color->red()->toInt();
|
||||||
$totalG += $color[1];
|
$totalG += $color->green()->toInt();
|
||||||
$totalB += $color[2];
|
$totalB += $color->blue()->toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user