/letter-avatar

User avatar using name initials - customizable, multilingual

Primary LanguagePHP

Letter Avatar for PHP

Generate user avatar using name initials letter.

letter-avatar

Based on the package of same name by Yoga Hanggara

Features

  • Data URI image ready (also save as PNG/JPG).
  • Works with several unicode blocks
  • Set saturation and luminosity to get consistent color
  • Customize size, shape: square, circle.
  • Small, fast.

Install

Via Composer

$ composer require sivarajd/letter-avatar

Implementation

<?php

use SivarajD\LetterAvatar\LetterAvatar;

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

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

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