Skip to content
Generate user avatar using name initials letter.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Change example Jun 9, 2018
src fix typo Feb 11, 2019
.gitignore Update Feb 11, 2019

Letter Avatar for PHP

Generate user avatar using name initials letter.



  • Data URI image ready (also save as PNG/JPG).
  • Consistent color.
  • Customize size, shape: square, circle.
  • Small, fast.


Via Composer

$ composer require yohang88/letter-avatar



use YoHang88\LetterAvatar\LetterAvatar;

$avatar = new LetterAvatar('Steven Spielberg');

// Square Shape, Size 64px
$avatar = new LetterAvatar('Steven Spielberg', 'square', 64);

// Save Image As PNG/JPEG
$avatar->saveAs('path/to/filename', LetterAvatar::MIME_TYPE_JPEG);
<img src="<?php echo $avatar ?>" />

To use static colour or custom colour use ->setColor($background, $foreground);

<img src="<?php echo $avatar->setColor('#000000', '#ffffff');?>" alt="">
You can’t perform that action at this time.