Reputation: 313
Trying to call a function, but I'm getting an error, the function is really long so here are the important bits.
Avatar.php
namespace App\Utility
class Avatar {
const spriteZ = 128;
public static function generateAvatar($hash, $size, $path) {
// .. code happened before this part, it all worked fine
$avatar = imagecreatetruecolor(self::spriteZ*3, self::spriteZ*3);
}
}
The User Controller:
use App\Utility\Avatar;
// ...further down in the code
Avatar::generateAvatar("abcde", 200, "/data/images/avatar.png");
The error I get is Call to undefined function App\Utility\imagecreatetruecolor()
. When I make the function call \imagecreatetruecolor(self::spriteZ*3, self::spriteZ*3)
I get an error of Call to undefined function imagecreatetruecolor()
which seems like the more correct error to have...
I do have php-gd
installed, and I am able to use this file as a standalone file (though I didn't have the namespace part).
Upvotes: 0
Views: 416
Reputation: 369
#Go to installed path php
and find php.ini
file.
#For example C:\xampp\php\php.ini
or everywhere in your computer.
#Open php.ini
file and find and change.
#Change from
;extension=gd
#Change to
extension=gd
#Change from
;gd.jpeg_ignore_warning = 1
#Change to
gd.jpeg_ignore_warning = 1
#Save changes in php.ini
file
#Reset Xampp Apachi
or anything you use
#Reset your computer
Upvotes: 0