Skip to content

Commit

Permalink
updated readme and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
nemoitis committed Mar 14, 2023
1 parent d2bb9b2 commit 994db83
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to `svg-avatar-generator` will be documented in this file.

## 1.2.0

- Support for custom extractor.
- New key `extractor` in **svg-avatar** config.

## 1.1.0

- Support for setting multiple sets of gradient colors.
Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/sowrensen/svg-avatar-generator/run-tests.yml?branch=main&label=Tests)](https://github.com/sowrensen/svg-avatar-generator/actions?query=workflow%3ATests+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/sowrensen/svg-avatar-generator.svg)](https://packagist.org/packages/sowrensen/svg-avatar-generator)

Generating SVG avatars on the fly is nothing new. There are a lot of free/paid services and packages to do that. So why
Generating SVG avatars on the fly is nothing new. There are tons of free/paid services and packages available to do that. So, why
another package for same task?

Well, this package has some subtle advantages over available packages, here's a few of them:
Well, this one has some subtle but nifty advantages over available packages, here's a few of them:

- [x] No external api call is required. 🤝🏼
- [x] No external api call is required, it's totally offline. 🛰️
- [x] Unlike some other available options, doesn't require heavy-weight image processing libraries like **Intervention**.
🧺
- [x] Doesn't have any binary dependency, so nothing needs to be installed on server. 🗃️
- [x] Supports gradient background. 🦜
- [x] Supports random gradients based on defined presets in config. 🦚
- [x] Ability to customize initials. ✍🏼
- [x] Ability to customize initials and extractor. ✍🏼

## Requirements

Expand Down Expand Up @@ -106,6 +106,33 @@ You can define the second initial using studly case. For example,
| Johndoe | JO |
| JohndoE | JE |

### Customize Extractor

The default initial extractor class produces results shown above. However, if you want something different, you can create your own Extractor class. To do so create a new class that implements `Sowren\SvgAvatarGenerator\Extractors\Extractor` interface. An ideal place to put this class would be under `App\Extractors` namespace in your app directory.

```php
<?php

namespace App\Extractors;

use Sowren\SvgAvatarGenerator\Extractors\Extractor;

class CustomExtractor implements Extractor
{
public function extract(string $text): string
{
// Write your custom logic and return initials
}
}
```

After doing that, set the class as default extractor in config.

```php
// ...
'extractor' => App\Extractors\CustomExtractor::class,
```

## Sample Output

<img src="https://user-images.githubusercontent.com/13097375/221879852-b8283a4a-f3ff-42a9-b37a-07cbc9bd0afe.png" height="128"/>
Expand Down

0 comments on commit 994db83

Please sign in to comment.