Download the PHP package lasserafn/php-initial-avatar-generator without Composer

On this page you can find all versions of the php package lasserafn/php-initial-avatar-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
lasserafn/php-initial-avatar-generator
Rate from 1 - 5
Rated 4.00 based on 1 reviews

Informations about the package php-initial-avatar-generator

Generate avatars with initials

Ever seen those avatars (basically everywhere) that has your initials — mine would be LR; Lasse Rafn — well this package allows you to generate those, in a simple manner.

Banner

Build Status OtterWise Coverage StyleCI Status Total Downloads Latest Stable Version License

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

There's also a api you can use: https://ui-avatars.com

Installation

You just require using composer and you're good to go! ` Rad, and long, package name.. huh? Sorry. I'm not very good with names.

Usage

As with installation, usage is quite simple. Generating a image is done by running: ``

Thats it! The method will return a instance of Image from Intervention so you can stream, download or even encode the image: `` You can also just pass along the initials, and it will use those. Should you just include a first name, it will use the first two letters of it.

SVG generation

``

Supported methods and parameters

Of cause, passing a name is not the only thing this sweet thing does!

Name (initials) - default: JD

``

AutoFont - default: false

Will detect language script (using lasserafn/php-string-script-language) and use a font that supports it.

``

Width - default: 48

``

Height - default: 48

``

Size - default: 48 (proxy for $avatar->width(X)->height(X))

``

Background color - default: #f0e9e9

``

Font color - default: #8b5d5d

``

Auto Color

``

Font file - default: /fonts/OpenSans-Regular.ttf

Two fonts with two variants are included:

The method will look for the font, if none found it will append __DIR__ and try again, and if not it will default to the first GD Internal Font. If you input an integer between 1 and 5, it will use a GD Internal font as per that number.

``

Font name (for SVGs) - default: Open Sans, sans-serif

``

Length - default: 2

``

Switching driver - default: gd

``

Rounded - default: false

``

Smooth - default: false

Makes rounding smoother with a resizing hack. Could be slower.

``

If you are going to use rounded(), you want to use smooth() to avoid pixelated edges. Disabled by default because it COULD be slower. I would recommend just rounding with CSS.

Font Size - default: 0.5

`` If the Image size is 50px and fontSize is 0.5, the font size will be 25px.

Chaining it all together

We will not use the ->font() method in this example; as I like the regular one.

``

Now, using that in a image (sized 48x48 pixels for retina): ` Will yield:

Result

Rounded for appearance; the actual avatar is a filled square

Font Awesome Support

The package supports FontAwesome (v5) and already distributes the free version as otf format (see /fonts folder).

However, when using FontAwesome you may want to display one specific icon instead of the user's initials. This package, therefore, provides a handy glyph($code) method to be used along with FontAwesome.

First, you need to "find" the respective unicode for the glyph you want to insert. For example, you may want to display a typical "user" icon (unicode: f007). The unicode is located near the name of the icon (e.g., see here the user icon as an example here: https://fontawesome.com/icons/user ).

An example for rendering a red avatar with a white "user" glyph would look like this:

Requirements

Script/Language support

Some letters are not supported by the default font files, so I added some fonts to add support. You must use autoFont() to enable this feature. Supported are:

Contributors

Open Source is best when supported by a community. Any size of contribution is very appreciated.

Supported Image Libraries (from intervention/image)


All versions of php-initial-avatar-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^7.1|^7.2|^7.3|^7.4|^8.0|^8.1|^8.2
ext-json Version *
intervention/image Version ^2.3
lasserafn/php-initials Version ^3.0
lasserafn/php-string-script-language Version ^0.4
meyfa/php-svg Version ^0.9.0
overtrue/pinyin Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lasserafn/php-initial-avatar-generator contains the following files

Loading the files please wait ....