PHP code example of vinicius73 / laravel-instantavatar

1. Go to this page and download the library: Download vinicius73/laravel-instantavatar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vinicius73 / laravel-instantavatar example snippets


Vinicius73\IAvatar\IAvatarServiceProvider::class,

'IAvatar' => Vinicius73\IAvatar\Facade\IAvatarFacade::class,

/**
 * Creates the image. Only the first letter will be passed to the image.
 * Ex.:
 * 'My String' -> output My
 * You can change this in the settings
 */
$avatar = IAvatar::random('My String');

/**
 * Save imagem in path
 * You can use `public::` Omit the full address /public
 */
$avatar->save('public::path/to/file.png');

/**
 * Output image in browser
 */
$avatar->display();

IAvatar::random('Vinicius')->save('public::avatars/vinicius.png')->display();

return array(
    'width'    => 150,
    'heigth'   => 150,
    'fontsize' => 80, // in px
    'chars'    => 2, // Character limit for every image
    'font' => array( // You can register or remove more sources with ease.
        'InstantAvatar::Comfortaa-Regular.ttf',
        'InstantAvatar::Roboto-Regular.ttf',
        'InstantAvatar::Ubuntu-Regular.ttf',
        'InstantAvatar::DroidSans.ttf'
    ),
    'overlay'  => 'InstantAvatar::glass.png', // A watermark that overlays the image
    'flat'     => false // Enables the flat mode
);