symforge/letter-avatar

Generate user avatar using name initials letter.

v1.1.6 2016-10-17 18:39 UTC

This package is not auto-updated.

Last update: 2024-12-11 20:07:23 UTC


README

Generate user avatar using name initials letter.

letter-avatar

Features

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

Install

Via Composer

$ composer require symforge/letter-avatar

Implementation

<?php

use YoHang88\LetterAvatar\LetterAvatar;

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

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

// Improved version:

$avatar = new LetterAvatar('Steven Spielberg', 'square', 64, ['#000000', '#dcdcdc']);
$avatar->setFont('OpenSans-Regular.ttf'); // you can use only filenames if you intend to use our own repo fonts otherwise
										  // use full relative path to your font.
$avatar->setColors(['#000000', '#dcdcdc', ....]); // you can pass this from constructor.
<img src="<?php echo $avatar ?>" />