PHPackages                             renfan/face - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. renfan/face

AbandonedArchivedLibrary[Image &amp; Media](/categories/media)

renfan/face
===========

A face SDK

v1.0.1(7y ago)220MITPHPPHP &gt;=7.1

Since Apr 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/renfan/face)[ Packagist](https://packagist.org/packages/renfan/face)[ RSS](/packages/renfan-face/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

 Face
======

[](#-face-)

🌈 基于阿里云平台的人脸识别组件。

[![Latest Version on Packagist](https://camo.githubusercontent.com/c57bd3a5d71d15ab4309ffac6989c4bf688f0255f46e2c4213260ae13443f073/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656e66616e2f666163652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/renfan/face)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/51d6b71369d205a9f3aa1cd77bc7ad9dca00f6c6ae630acc86668efb5be9ce7b/68747470733a2f2f7472617669732d63692e6f72672f72656e66616e2f666163652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/renfan/face)[![StyleCI build status](https://camo.githubusercontent.com/6d2b38268ae2165847dd279b06af2c74bff5c6c5f96f320fc4e3c69e5da5f0cc/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3138303038383033392f736869656c64)](https://camo.githubusercontent.com/6d2b38268ae2165847dd279b06af2c74bff5c6c5f96f320fc4e3c69e5da5f0cc/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3138303038383033392f736869656c64)[![996.icu](https://camo.githubusercontent.com/ac8f294a80f65338db545230f1a881b9a382204a1f187c6ff40ee679d42d40ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d3939362e6963752d7265642e737667)](https://996.icu)

安装
--

[](#安装)

```
$ composer require renfan/face -vvv
```

配置
--

[](#配置)

> 在使用本扩展前，你需要开通阿里云人脸识别服务 [](https://face.data.aliyun.com/console)，并获取 AccessKey

输入命令添加配置文件`face.php`

```
php artisan vendor:publish --provider="Renfan\Face\ServiceProvider"
```

```
return [
    'key' => env('ALI_ACCESS_KEY'),
    'secret' => env('ALI_ACCESS_KEY_SECRET'),
];
```

在 .env 文件中加入阿里云AccessKey

```
ALI_ACCESS_KEY=xxx
ALI_ACCESS_KEY_SECRET=xxx
```

使用
--

[](#使用)

### 人脸比对 `verify`

[](#人脸比对-verify)

#### url 方式

[](#url-方式)

```
$image1 = 'a.com/1.jpg';
$image2 = 'a.com/2.jpg';
$res = app('face')->verifyByUrl($image1, $image2);
```

#### base64 方式

[](#base64-方式)

```
$image1 = 'xxx';
$image2 = 'xxx';
$res = app('face')->verifyByContent($image1, $image2);
```

#### 结果

[](#结果)

```
{
  "confidence": 99.99996948242188,
  "thresholds": [
    61,
    69,
    75
  ],
  "rectA": [
    280,
    350,
    430,
    590
  ],
  "rectB": [
    280,
    350,
    430,
    590
  ],
  "errno": 0,
  "request_id": "e1a959ba-76e6-4e02-a455-605d9e1fd421"
}
```

字段说明，见 [人脸比对API调用说明](https://help.aliyun.com/knowledge_detail/53535.html)

### 人脸检测定位

[](#人脸检测定位)

#### url 方式

[](#url-方式-1)

```
$image = 'a.com/1.jpg';
$res = app('face')->detectByUrl($image);
```

#### base64 方式

[](#base64-方式-1)

```
$image = 'xxxx';
$res = app('face')->detectByContent($image);
```

#### 结果

[](#结果-1)

```
{
  "face_num": 1,
  "face_rect": [
    280,
    350,
    430,
    590
  ],
  "face_prob": [
    1
  ],
  "pose": [
    0.20114891231060028,
    -0.4934055507183075,
    0.7045236229896545
  ],
  "landmark_num": 105,
  "landmark": [
    290.78765869140625,
    549.17578125
  ],
  "iris": [
    391.3370666503906,
    577.3011474609375,
    17.18027114868164,
    593.888916015625,
    577.9119873046875,
    17.18027114868164
  ],
  "errno": 0,
  "request_id": "3a91b868-5af9-4980-a088-54cbacf2e40b"
}
```

字段说明，见 [人脸检测定位API调用说明](https://help.aliyun.com/knowledge_detail/53399.html)

### 人脸属性识别

[](#人脸属性识别)

#### url 方式

[](#url-方式-2)

```
$image = 'a.com/1.jpg';
$res = app('face')->attributeByUrl($image);
```

#### base64 方式

[](#base64-方式-2)

```
$image = 'xxxx';
$res = app('face')->attributeByContent($image);
```

#### 结果

[](#结果-2)

```
{
  "face_num": 1,
  "face_rect": [
    280,
    350,
    430,
    590
  ],
  "face_prob": [
    1
  ],
  "pose": [
    0.20114891231060028,
    -0.4934055507183075,
    0.7045236229896545
  ],
  "landmark_num": 105,
  "landmark": [
    290.78765869140625,
    549.17578125,
    -0.00849494431167841
  ],
  "errno": 0,
  "request_id": "e54be58b-1190-42bf-9abe-ebbb2bc9eabb"
}
```

字段说明，见 [人脸属性识别API调用说明](https://help.aliyun.com/knowledge_detail/53520.html)

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2642d ago

Major Versions

0.1.0 → 1.0.02019-04-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/a44306b3d0af6ad7d4d0b235c86b0aa8df8e0b7ca3dad48e7249484bf56a9075?d=identicon)[renfan](/maintainers/renfan)

---

Top Contributors

[![ddpmz](https://avatars.githubusercontent.com/u/3666795?v=4)](https://github.com/ddpmz "ddpmz (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/renfan-face/health.svg)

```
[![Health](https://phpackages.com/badges/renfan-face/health.svg)](https://phpackages.com/packages/renfan-face)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

16653.6k2](/packages/gravatarphp-gravatar)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
