2017 © Pedro Peláez
 

library avatar-generator

Avatar generator by username, file or url.

image

zertex/avatar-generator

Avatar generator by username, file or url.

  • Thursday, June 28, 2018
  • by Error202
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Avatar Generator

Generate avatar for user by his name, file or url., (*1)

Latest Stable Version Total Downloads, (*2)

Features

  • Saving to PNG format
  • Generate avatar by username
  • Generate avatar from file or url (http only)
  • Auto select background color by username
  • Contrast color for text
  • Font face and size customize
  • PNG Textures for background

Dependencies

  • PHP 7
  • PHP GD

Installation

Install with composer:, (*3)

composer require zertex/avatar-generator

or add, (*4)

"zertex/avatar-generator": "*"

to the require section of your composer.json file., (*5)

Configuration

$options = AvatarOptions::create()
            ->setFont('path to ttf font')
            ->setWidth(300)
            ->setFontSize(200)
            ->setTexturesFolder('path to textures folder')
            ->setImagesFolder('path to generated images folder')
            ->setImagesUrl('url to images folder')
            ->setSalt('random salt');
  • setFont - Path to TTF font
  • setWidth - Width & height avatar image file. Default: 300
  • setFontSize - Font size. Default: 200
  • setTexturesFolder - Path to textures folder. Used only PNG textures
  • setImagesFolder - Path to image folder.
  • setImagesUrl - Url for generating complete link to image
  • setSalt - Random text for new image file name

Using

Generate avatar image by username, (*6)

$image_src = Avatar::init('John Smith', $options, [result file name])
               ->username()
               ->texture('TEXTURE_NAME')
               ->text()
               ->get_file_name();

Generate avatar image from file, (*7)

$image_src = Avatar::init('John Smith', $options, [result file name])
               ->file('/path/to/file')
               ->texture('TEXTURE_NAME')
               ->text()
               ->get_file_name();

Generate avatar image from url, (*8)

$image_src = Avatar::init('John Smith', $options, [result file name])
               ->file('http://your-site.com/image.jpg')
               ->texture('TEXTURE_NAME')
               ->text()
               ->get_file_name();

You can exclude texture or text from chain for exclude them, (*9)

Textures

You can use PNG texture with transparancy. Every texture must consist of 2 files (back & white). His names myst be:, (*10)

TEXTURE_NAME . '-' . COLOR . '.png'
  • TEXTURE_NAME - Any words. In texture() method you can use array of TEXTURE_NAME for random
  • COLOR - Must be black or white

Screenshot

alt text, (*11)

Yii2 extension

Avater generator extension for Yii2 here: https://github.com/zertex/yii2-avatar-generator, (*12)

There you can find 2 textures and Play-Bold.ttf font, (*13)

Examples

https://zertex.ru/yii2-avatar-generator, (*14)

The Versions

28/06 2018

dev-master

9999999-dev

Avatar generator by username, file or url.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=7.0.0

 

The Development Requires

avatar userpic

28/06 2018

1.1.2

1.1.2.0

Avatar generator by username, file or url.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=7.0.0

 

The Development Requires

avatar userpic