yohang88 / letter-avatar
Generate user avatar using name initials letter.
2.3.0
2023-11-14 13:31 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 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'); $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="">