tron / material-design-avatars
为Android用户创建类似Gmail或Messager的材质设计头像。
1.3
2016-05-09 03:13 UTC
Requires
- php: >=4.0.6
This package is not auto-updated.
Last update: 2024-09-20 18:03:16 UTC
README
为用户创建类似Google Messager的材质设计头像。
可能不是独一无二的,但看起来比Identicon或Gravatar更好。
语言支持
屏幕截图
需求
- PHP GD库。
初始化
<?php require(dirname(__FILE__) . "/src/MaterialDesign.Avatars.class.php"); /* 'X' : The character that you want to fill to the avatar. 512 (pixel) : The size of the avatar. */ $Avatar = new MDAvtars('X', 512); ?>
用法
在浏览器中显示头像
<?php $Avatar->Output2Browser(); ?>
<? //You can resize the ouput size again here. $OutputSize = 256; $Avatar->Output2Browser($OutputSize); ?>
将头像保存到文件
<?php $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); ?>
释放内存
<?php $Avatar->Free(); ?>
注意
如果您不需要中文支持,您可以删除src/fonts/SourceHanSansCN-Normal.ttf
。
如果您删除了src/fonts/SourceHanSansCN-Normal.ttf
,在您输入中文字符时,它将自动提取中文字符的拼音首字母,而不是原始输入。
$Avatar = new MDAvtars('林', 512);//The pinyin of "林" is "Lin".
如果您删除了src/fonts/SourceHanSansCN-Normal.ttf
,这将与以下相同。
$Avatar = new MDAvtars('L', 512);//The first letter of that pinyin is "Lin".
字体
许可证
Copyright 2015 Canbin Lin (lincanbin@hotmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.