leomarriel/laravel-face-detector
Composer 安装命令:
composer create-project leomarriel/laravel-face-detector
包简介
A Face Detector for Laravel
关键字:
README 文档
README
A Laravel package to handle face detection in an image
Current Features
- reading a local or remote file
- external url support
- multiple ways available output the found face
- file validation
Installation
composer require leomarriel/laravel-face-detector
Configuration
Laravel without auto-discovery:
If you don't use auto-discovery, add the FaceDetectorServiceProvider to the providers array in config/app.php
'providers' => [ ... Leomarriel\FaceDetector\FaceDetectorServiceProvider::class, ... ],
Copy configuration to your project:
php artisan vendor:publish --tag=facedetector-config
By executing above command the package configuration will be published to config/facedetector.php
Config file
There are two configuration options available
config/facedetector.php is an asociative array with the following possible keys:
disk(string): the storage disk for file save on command outputsave().noFoundFaceException(bool): Disable the exception when a face is not foundpadding(array): Define a padding around the found face
Usage
Direct use, no facades:
You can create a new FaceDetector instance and load a local or remote file
use Leomarriel\FaceDetector\FaceDetector; $face = new FaceDetector(); $face->loadFile('path/to/image.jpg'); $face->preview();
If you want to use the facade to face detection, add this to your facades in config/app.php:
'aliases' => [ ... 'FaceDetector' => Leomarriel\FaceDetector\Facades\FaceDetector::class, ... ],
Use the facade to face detection
There are currently two ways to load the file:
From Path
use FaceDetector; $face = FaceDetector::loadFile('path/to/image.jpg')->preview();
From Url
use FaceDetector; $face = FaceDetector::loadUrl('https://url/to/image.jpg')->preview();
Output details
Check all available output ways
use FaceDetector; $face = FaceDetector::loadFile('path/to/image.jpg');
$face->found(); // (bool) Return a boolean whether or not a face was found in the file
$face->face(); // (array) Return an array with the position of the found face
$face->preview(); // Return a preview of the face found with a tag
$face->json(); // Return the found face in json format
$face->stream(); // Return a response with found face cropped in JPG to show in browser
$face->output(); // Return a jpg string file with the found face
$face->save(); // Physically save the face found
Save details
You can save the found face quickly with $face->save() output.
The script will create a unique name for your file and store it in the facedetector folder in your storage.
$face->save(); // Physically save the face found on folder "facedetector" in your storage
You can set your preferred storage location:
$face->save('path/to/save'); // Physically save the found face with a random name in a defined path.
Take full control, set the storage path and file name to be saved. Save the file as JPG or PNG, it's your choice.
$face->save('path/to/save', 'new-image.jpg'); // Physically save the found face with a defined path and name.
If the save succeeds, will return the following data:
[
'filename' => 'Saved file name',
'size' => 'file size after cropping',
'path' => 'path to file location relative to the disk storage',
'url' => 'public url to access the file in browser'
]
☕️ Buy Me a Coffe
I'm happy to be able to contribute to your project, if this package helped you in any way, could you repay me with a coffee? Hugs!
leomarriel/laravel-face-detector 适用场景与选型建议
leomarriel/laravel-face-detector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 09 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「detection」 「laravel」 「detector」 「face」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 leomarriel/laravel-face-detector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 leomarriel/laravel-face-detector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 leomarriel/laravel-face-detector 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shim repository for phpmd/phpmd
Language detection in PSR-15 middleware
Parses a user agent string to detect Internet Explorer
The Azure package for opentelemetry-php
Agent is a PHP/Laravel package for detecting devices/bots via the http request.
统计信息
- 总下载量: 38
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-01