maxvoronov / avatarix
Avatars generating library
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
pkg:composer/maxvoronov/avatarix
Requires
- php: ^7.0
- imagine/imagine: ^0.7.1
Requires (Dev)
This package is not auto-updated.
Last update: 2025-10-07 22:35:52 UTC
README
Install
The preferred way to install this extension is through composer:
composer require maxvoronov/avatarix
Usage
Library can generate 8-bits avatar by any string. This package use Imagine for processing.
use MaxVoronov\Avatarix; use MaxVoronov\Avatarix\SpriteCollection; $avatarix = new Avatarix; $avatarix->setPayload('username'); // You can use here user ID or email $avatarix // Set collections of avatar parts ->appendCollection(SpriteCollection::init(__DIR__ . '/assets/bg/')) ->appendCollection(SpriteCollection::init(__DIR__ . '/assets/faces/')) ->appendCollection(SpriteCollection::init(__DIR__ . '/assets/clothes/')) ->appendCollection(SpriteCollection::init(__DIR__ . '/assets/mouths/')) ->appendCollection(SpriteCollection::init(__DIR__ . '/assets/eyes/')) ->appendCollection(SpriteCollection::init(__DIR__ . '/assets/hairs/')); $userAvatar = $avatarix->render(); $userAvatar->save('/path/to/avatar.png'); // Save generated avatar into file $userAvatar->show('png'); // ... and output with image headers
You can also look at an example.
Special Thanks
Special thanks to @matveyco and his 8biticon Project for avatar sprites.
License
The MIT License (MIT). Please see License File for more information.