malenki/aleavatar 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

malenki/aleavatar

Composer 安装命令:

composer require malenki/aleavatar

包简介

README 文档

README

Generator of random avatars aka identicons, like you can see on Stackoverflow for example!

How it works?

This PHP library create a md5 sum from the string you give.

Each two character is taken, so, we get a string of 32 ÷ 2 = 16 characters.

For this 16 hexadecimal characters, we take the first 8 of them to choose basic shapes to use in the picture, the 6 followings are used to create the foreground color, the last but one is used to place basic shapes and the last is used to choose the rotation way of each quarter part.

What do I get?

You get by default a picture of 128px × 128px. This picture can be SVG or PNG. For PNG, you must have one of this PHP modules: ImageMagick or GD.

I recommand you the first one. GD is a fallback very poor (no scaling and antialias if you have PHP version prior to 5.5).

You can display PNG images or store them. As you want.

SVG can be used into HTML5 document or as standalone SVG file.

How to install it?

Using composer it is very simple.

Just put this into your composer.json file:

require: "malenki/aleavatar": "dev-master"

Do you have some examples?

Yes. The first, very simple, generates a (pseudo)random SVG avatar and save it into my_avatar.svg file:

$a = new Malenki\Aleavatar\Aleavatar();
$a->generate()->svg('my_avatar.svg');

Now, this one generates one SVG avatar to display into HTML5 based on the string "My avatar is fun!":

$a = new Malenki\Aleavatar\Aleavatar("My avatar is fun!");
$strSVG = $a->generate()->svgForHtml5();

The same but to generate PNG to display on browser :

$a = new Malenki\Aleavatar\Aleavatar("My avatar is fun!");
header('Content-Type: image/png');
echo $a->generate()->png();
exit();

You can change size in pixel too:

$a = new Malenki\Aleavatar\Aleavatar();
$a->generate(200)->svg('my_avatar.svg');

Note: If you have GD as fallback, and your PHP version is inferior to 5.5, then you have not scaling.

Enjoy!

统计信息

  • 总下载量: 65
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-11-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固