<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lasserafn / php-initial-avatar-generator example snippets
$avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar();
$image = $avatar->name('Lasse Rafn')->generate();
return $image->stream('png', 100);
LasseRafn\InitialAvatarGenerator\InitialAvatar;
header('Content-Type: image/png'); // Set the content type to PNG
$avatar = new InitialAvatar();
$name = isset($_GET['name']) ? $_GET['name'] : 'Default User';
// Generate the image
$image = $avatar->name($name)->generate();
// Stream the image directly to the output
echo $image->stream('png', 100);
exit;
$avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar();
echo $avatar->name('Lasse Rafn')->generateSvg()->toXMLString(); // returns SVG XML string
// will be 96 pixels wide.
$image = $avatar->width(96)->generate();
// will be 96 pixels tall.
$image = $avatar->height(96)->generate();
// will be 96x96 pixels.
$image = $avatar->size(96)->generate();
// will be red
$image = $avatar->background('#ff0000')->generate();
// will be red
$image = $avatar->color('#ff0000')->generate();
// Will choose a background color based on `name` and a contrasting font color. The color for a specific name will always be the same.
$image = $avatar->autoColor()->generate();
// will be Semibold
$image = $avatar->font('/fonts/OpenSans-Semibold.ttf')->generate();
// note that we
// 1) use glyph() instead of name
// 2) change the font to FontAwesome!
return $avatar->glyph('f007')
->font('/fonts/FontAwesome5Free-Regular-400.otf')
->color('#fff')
->background('#ff0000')
->generate()
->stream('png', 100);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.