这篇文章主要介绍如何在Laravel上使用万象优图,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
如何在 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(
"https://cache.tdyun.com/upload/information/20210522/355/681909.jpg",
"https://cache.tdyun.com/upload/information/20210522/355/681910.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)以上是“如何在Laravel上使用万象优图”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注天达云行业资讯频道!