Last active
May 18, 2022 08:50
-
-
Save binarykore/a0a4971ae4becbc912a77013f70465e0 to your computer and use it in GitHub Desktop.
Initial or Word-based Avatar Image Generator using GD Imaging..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function initialAvatar($_string){ | |
| $_imagewidth = 240; | |
| $_imageheight = 240; | |
| $_font = 5; | |
| $_width = imagefontwidth($_font) * strlen($_string); | |
| $_height = imagefontheight($_font); | |
| $_formula = []; | |
| $_formula["a"] = ($_imagewidth / 2) - ($_width / 2); | |
| $_formula["b"] = ($_imageheight / 2) - ($_height / 2); | |
| $_avatar = imagecreatetruecolor(($_imagewidth),($_imageheight)); | |
| $_bgColor = imagecolorallocate($_avatar,211,211,211); | |
| imagefill($_avatar,0,0,$_bgColor); | |
| $_avatarTxtColor = imagecolorallocate($_avatar,0,0,0); | |
| imagestring($_avatar,$_font,$_formula["a"],$_formula["b"],$_string,$_avatarTxtColor); | |
| ob_start(); | |
| imagepng($_avatar,NULL,9); | |
| $_BlobImage = ob_get_clean(); | |
| return($_BlobImage); | |
| }// | |
| Header("Content-Type:image/png"); | |
| echo(initialAvatar("Hello World")); | |
| //Initial or Word-based Avatar Image | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment