mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
fix: Handle exceptions in image processing functions
- Catch exceptions when reading image content to prevent errors. - Adjust image resizing dimensions for better display.
This commit is contained in:
@@ -13,16 +13,20 @@ function getRoleIcon($roleName): string
|
||||
'Support' => 'gm-support.png',
|
||||
];
|
||||
|
||||
return asset('img/'.$roleIcons[$roleName]);
|
||||
return asset('img/' . $roleIcons[$roleName]);
|
||||
}
|
||||
|
||||
function getAverageColorFromImageUrl($imageUrl): string
|
||||
{
|
||||
$imgManager = new ImageManager(new Driver());
|
||||
|
||||
$img = $imgManager->read(file_get_contents($imageUrl));
|
||||
try {
|
||||
$img = $imgManager->read(file_get_contents($imageUrl));
|
||||
} catch (Exception $e) {
|
||||
return '#904f2c';
|
||||
}
|
||||
|
||||
$img->resize(24, 24);
|
||||
$img->resize(32, 32);
|
||||
|
||||
$totalR = 0;
|
||||
$totalG = 0;
|
||||
|
||||
Reference in New Issue
Block a user