filsh / letter-avatar
Generate user avatar using name initials letter.
2.0.1
2018-07-15 05:09 UTC
Requires
- php: >=7.0.0
- ext-mbstring: *
- intervention/image: ^2.3
Requires (Dev)
- phpunit/phpunit: 4.*
- roave/security-advisories: dev-master
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 yohang88/letter-avatar
Implementation
<?php use filsh\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'); $avatar->saveAs('path/to/filename', LetterAvatar::MIME_TYPE_JPEG); // Own Color Provider $colorProvider = new \filsh\LetterAvatar\RandomColorProvider(1.3); // or $colorProvider = new \filsh\LetterAvatar\ColorPaletteProvider([ "#1abc9c", "#2ecc71", "#3498db", "#9b59b6", "#34495e", "#16a085", "#27ae60", "#2980b9", "#8e44ad", "#2c3e50", "#f1c40f", "#e67e22", "#e74c3c", "#a5a8a8", "#95a5a6", "#f39c12", "#d35400", "#c0392b", "#bdc3c7", "#7f8c8d", ]); $avatar = new LetterAvatar('Steven Spielberg', 'square', 64, $colorProvider);
<img src="<?php echo $avatar ?>" />