admin管理员组文章数量:1130349
php 美颜,使用face++实现人像美颜
face++人像美颜接口地址:
参数说明:
是否必选
参数名
类型
参数说明
必选
api_key
string
调用此API的API key
必选
api_secret
string
调用此API的API secret
必选
image_base64
string
base64编码的二进制图片数据
可选
whitening
int
美白程度,取值范围[0,100]
0无美白效果,100代表最高程度
本参数默认值为 50
可选
smoothing
int
磨皮程度,取值范围 [0,100]
0无磨皮效果,100代表最高程度
本参数默认值为 50
可选
thinface
int
瘦脸程度,取值范围 [0,100]
0无瘦脸效果,100代表最高程度
本参数默认值为50
可选
shrink_face
int
小脸程度,取值范围 [0,100]
0无小脸效果,100代表最高程度
本参数默认值为50
可选
enlarge_eye
int
大眼程度,取值范围 [0,100]
0无大眼效果,100代表最高程度
本参数默认值为50
可选
remove_eyebrow
int
去眉毛程度,取值范围 [0,100]
0无去眉毛效果,100代表最高程度
本参数默认值为50
可选
filter_type
string
滤镜名称,参数参考下面的表格
filter_type 滤镜名称参数列表:
black_white
黑白
calm
平静
sunny
晴天
trip
旅程
beautify
美肤
wangjiawei
王家卫
cutie
唯美
macaron
可人儿
new_york
纽约
sakura
樱花
17_years_old
十七岁
clight
柔光灯
tea_time
下午茶
whiten
亮肤
chaplin
卓别林
flowers
花香
memory
回忆
ice_lady
冰美人
paris
巴黎
times
时光
lomo
LOMO
old_times
旧时光
spring
早春
story
故事
abao
阿宝色
wlight
补光灯
warm
暖暖
glitter
绚烂
lavender
薰衣草
chanel
香奈儿
prague
布拉格
old_dream
旧梦
blossom
桃花
pink
粉黛
jiang_nan
江南
接口返回的result参数就是美颜过后的base64图片,简单实现如下,这里我是用的时Yii框架的yiisoft/yii2-httpclient拓展实现
//接口数据
$url = '';
$img = file_get_contents(XXX);//人像图片
$img = base64\_encode($img);
$data = [
'api_key' => 'XXX',
'api_secret' => 'XXX',
'image_base64' => $img,
'whitening' => 80,
'smoothing' => 0,
'thinface' => 0,
'shrink_face' => 0,
'enlarge_eye' => 0,
'filter_type' => 'beautify'
];
$client = new Client();
$response = $client->createRequest()
->setMethod('POST') // 请求方式
->setUrl($url) // 请求地址
->setData($data) //数据传数组
->setHeaders(['Content-Type'=>'multipart/form-data']) //header
->send();
if ($response->isOk) {
//保存美颜图片
$file = time() . 'jpg';
file_put_contents($file, base64_decode($response->data['result']));
} else {
echo $response->data['error\_message'];//错误信息
}
php 美颜,使用face++实现人像美颜
face++人像美颜接口地址:
参数说明:
是否必选
参数名
类型
参数说明
必选
api_key
string
调用此API的API key
必选
api_secret
string
调用此API的API secret
必选
image_base64
string
base64编码的二进制图片数据
可选
whitening
int
美白程度,取值范围[0,100]
0无美白效果,100代表最高程度
本参数默认值为 50
可选
smoothing
int
磨皮程度,取值范围 [0,100]
0无磨皮效果,100代表最高程度
本参数默认值为 50
可选
thinface
int
瘦脸程度,取值范围 [0,100]
0无瘦脸效果,100代表最高程度
本参数默认值为50
可选
shrink_face
int
小脸程度,取值范围 [0,100]
0无小脸效果,100代表最高程度
本参数默认值为50
可选
enlarge_eye
int
大眼程度,取值范围 [0,100]
0无大眼效果,100代表最高程度
本参数默认值为50
可选
remove_eyebrow
int
去眉毛程度,取值范围 [0,100]
0无去眉毛效果,100代表最高程度
本参数默认值为50
可选
filter_type
string
滤镜名称,参数参考下面的表格
filter_type 滤镜名称参数列表:
black_white
黑白
calm
平静
sunny
晴天
trip
旅程
beautify
美肤
wangjiawei
王家卫
cutie
唯美
macaron
可人儿
new_york
纽约
sakura
樱花
17_years_old
十七岁
clight
柔光灯
tea_time
下午茶
whiten
亮肤
chaplin
卓别林
flowers
花香
memory
回忆
ice_lady
冰美人
paris
巴黎
times
时光
lomo
LOMO
old_times
旧时光
spring
早春
story
故事
abao
阿宝色
wlight
补光灯
warm
暖暖
glitter
绚烂
lavender
薰衣草
chanel
香奈儿
prague
布拉格
old_dream
旧梦
blossom
桃花
pink
粉黛
jiang_nan
江南
接口返回的result参数就是美颜过后的base64图片,简单实现如下,这里我是用的时Yii框架的yiisoft/yii2-httpclient拓展实现
//接口数据
$url = '';
$img = file_get_contents(XXX);//人像图片
$img = base64\_encode($img);
$data = [
'api_key' => 'XXX',
'api_secret' => 'XXX',
'image_base64' => $img,
'whitening' => 80,
'smoothing' => 0,
'thinface' => 0,
'shrink_face' => 0,
'enlarge_eye' => 0,
'filter_type' => 'beautify'
];
$client = new Client();
$response = $client->createRequest()
->setMethod('POST') // 请求方式
->setUrl($url) // 请求地址
->setData($data) //数据传数组
->setHeaders(['Content-Type'=>'multipart/form-data']) //header
->send();
if ($response->isOk) {
//保存美颜图片
$file = time() . 'jpg';
file_put_contents($file, base64_decode($response->data['result']));
} else {
echo $response->data['error\_message'];//错误信息
}
本文标签: php 美颜使用face实现人像美颜
版权声明:本文标题:php 美颜,使用face++实现人像美颜 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/IT/1694638028a254364.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论