PHP code example of lincanbin / material-design-avatars

1. Go to this page and download the library: Download lincanbin/material-design-avatars 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/ */

    

lincanbin / material-design-avatars example snippets



'         : The character that you want to fill to the avatar.
512 (pixel) : The size of the avatar.
*/
$Avatar = new Md\MDAvatars('X', 512);


// composer 

$Avatar = new MDAvatars('X', 512);


$Avatar->Output2Browser();


// You can resize the ouput size again here.
$OutputSize = 256;
$Avatar->Output2Browser($OutputSize);
// Output Base64 encoded image data.
$Avatar->Output2Base64($OutputSize);
// Get an image resource identifier.
$Avatar->Output2ImageResource($OutputSize);


$Avatar->Save('./avatars/Avatar.png');
//You can resize the size you want to save again here.
$Avatar->Save('./avatars/Avatar256.png', 256);
$Avatar->Save('./avatars/Avatar128.png', 128);
$Avatar->Save('./avatars/Avatar64.png', 64);


$Avatar->Free();

$Avatar = new MDAvtars('林', 512);//The pinyin of "林" is "Lin".

$Avatar = new MDAvtars('L', 512);//The first letter of that pinyin is "Lin".