Skip to content

👤 Generate user avatar using name initials letter.

License

Notifications You must be signed in to change notification settings

tal7aouy/avatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Avatar for PHP

Generate user avatar using name initials 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 tal7aouy/avatar

Implementation

<?php

use Tal7aouy/Avatar\Avatar;

$avatar = new Avatar('Mhammed Talhaouy');

// Square Shape, Size 64px
$avatar = new Avatar('Mhammed Talhaouy', 'square', 64);

// Save Image As PNG/JPEG
$avatar->saveAs('path/to/filename');
$avatar->saveAs('path/to/filename', Avatar::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="" />

License

Avatar is open-sourced software licensed under the MIT license.

About

👤 Generate user avatar using name initials letter.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages