symforge / letter-avatar
Generate user avatar using name initials letter.
v1.1.6
2016-10-17 18:39 UTC
Requires
- php: >=5.5.0
- intervention/image: ^2.3
Requires (Dev)
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
README
Generate user avatar using name initials letter.
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 ?>" />