dealerdirect/letter-avatar

Generate user avatar using name initials letter.

2.0.2 2018-12-18 11:38 UTC

This package is auto-updated.

Last update: 2024-12-19 00:49:32 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 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 ?>" />