【腾讯云的1001种玩法】 Laravel 整合万向优图图片管理能力,打造高效图片处理服务
版权声明:本文由白宦成原创文章,转载请注明出处:
文章原文链接:https://www.qcloud.com/community/article/574549001488234358
来源:腾云阁 https://www.qcloud.com/community
什么是万象优图
万象优图是腾讯云为开发者提供图片智能鉴黄、图片内容识别、人脸识别、OCR识别等服务;也可以根据需求提供定制化的图片识别服务;同时也提供灵活的图像编辑服务,如裁剪、压缩,水印等,满足您的各种业务场景图片需求。
如何在 Laravel 上使用万象优图?
安装
执行 composer 命令安装拓展
composer require yuecode/image
在config/app.php中的 Provider 中添加
\Yuecode\Image\ImageProvider::class,
执行 php artisan vendor:publish,将自动在 config/ 目录下生成 image.php 文件,修改配置文件中的对应选项。
配置完成后,在需要使用的文件中使用
use Yuecode\Image\YouTu;
然后使用静态方法调用
比如
$res = YouTu::pornDetectUrl(
array(
"http://www.bz55.com/uploads/allimg/140805/1-140P5162300-50.jpg",
"http://img.taopic.com/uploads/allimg/130716/318769-130G60P30462.jpg"
)
);
dd($res);
方法列表
| 方法名 | 备注 |
|---|---|
| uploadImage | 上传图片,万象优图V2接口 |
| statImage | 查询图片信息,万象优图V2接口 |
| copyImage | 复制图片,万象优图V2接口 |
| delImage | 删除图片,万象优图V2接口 |
| uploadImageV1 | 上传图片,万象优图V1接口 |
| statImageV1 | 查询图片信息,万象优图V1接口 |
| copyImageV1 | 复制图片,万象优图V1接口 |
| delImageV1 | 删除图片,万象优图V1接口 |
| uploadVideo | 上传视频 |
| statVideo | 查看视频状态 |
| delVideo | 删除视频文件 |
| pornDetect | 智能鉴黄,参数为URL |
| pornDetectUrl | 多图片智能鉴黄,参数为URL构成的array |
| pornDetectFile | 图片文件只能鉴黄,参数为文件的array |
示例代码
上传图片
$res = YouTu::uploadImage($request->file('x')->getRealPath());
dd($res)
智能鉴黄
$res = YouTu::pornDetect('http://img.taopic.com/uploads/allimg/130716/318769-130G60P30462.jpg')
dd($res)
浙公网安备 33010602011771号