aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Avatar/Avatar.php
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-04-09 10:48:27 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-04-09 10:48:27 +0200
commit6d7ff2e85a97a5d9971a39c2f89f3602c4f3ac51 (patch)
tree39b128a7516dbb9ac431b670fecf68fc01fca76e /lib/private/Avatar/Avatar.php
parent8177fc8aacf0d4e1f5a1fcfa7c0f845b25527429 (diff)
downloadnextcloud-server-6d7ff2e85a97a5d9971a39c2f89f3602c4f3ac51.tar.gz
nextcloud-server-6d7ff2e85a97a5d9971a39c2f89f3602c4f3ac51.zip
fix: Fix typing issues related to resource migration
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Avatar/Avatar.php')
-rw-r--r--lib/private/Avatar/Avatar.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php
index 69bf9bacfcf..020c509b86c 100644
--- a/lib/private/Avatar/Avatar.php
+++ b/lib/private/Avatar/Avatar.php
@@ -151,6 +151,7 @@ abstract class Avatar implements IAvatar {
/**
* Generate png avatar with GD
+ * @throws \Exception when an error occurs in gd calls
*/
protected function generateAvatar(string $userDisplayName, int $size, bool $darkTheme): string {
$text = $this->getAvatarText();
@@ -158,6 +159,9 @@ abstract class Avatar implements IAvatar {
$backgroundColor = $textColor->alphaBlending(0.1, $darkTheme ? new Color(0, 0, 0) : new Color(255, 255, 255));
$im = imagecreatetruecolor($size, $size);
+ if ($im === false) {
+ throw new \Exception('Failed to create avatar image');
+ }
$background = imagecolorallocate(
$im,
$backgroundColor->red(),
@@ -169,6 +173,9 @@ abstract class Avatar implements IAvatar {
$textColor->green(),
$textColor->blue()
);
+ if ($background === false || $textColor === false) {
+ throw new \Exception('Failed to create avatar image color');
+ }
imagefilledrectangle($im, 0, 0, $size, $size, $background);
$font = __DIR__ . '/../../../core/fonts/NotoSans-Regular.ttf';
@@ -191,7 +198,7 @@ abstract class Avatar implements IAvatar {
/**
* Calculate real image ttf center
*
- * @param resource $image
+ * @param \GdImage $image
* @param string $text text string
* @param string $font font path
* @param int $size font size