赞
踩
百度图像增强与特效:基于领先的深度学习图像处理技术,对质量较低的图片进行去雾、无损放大、对比度增强等多种处理,优化重建高清图像。
├── AipImageProcess.php //图像效果增强
└── lib
├── AipHttpClient.php //内部http请求类
├── AipBCEUtil.php //内部工具类
└── AipBase //Aip基类
require_once 'libs/AipImageProcess.php';
// 你的 APPID AK SK
const APP_ID = '25269***';
const API_KEY = 'LZCiWnVXLUaxkMA***';
const SECRET_KEY = 'hdFwq03nxC4oLdVVYXGHl4***';
$client = new AipImageProcess(APP_ID, API_KEY, SECRET_KEY);
/*""" 如果有可选参数 """*/
$options = array("type" => "anime", "mask_id" => 3);
$image = file_get_contents('wujing.jpg');
/*组合新的base64字符串*/
$fileName = "data:image/jpg;base64," . $obj['image'];
//生成本地图片;
base64_image_content($fileName, 'upload');
$res = array();
$res['log_id'] = $obj["log_id"];
$res['code'] = "1";
$res['msg'] = "success";
die(json_encode($res));
/** * 将Base64图片转换为本地图片并保存 * @param $base64_image_content ,保存的Base64 * @param $path ,保存的路径 */ function base64_image_content($base64_image_content, $path) { //匹配出图片的格式 if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)) { $type = $result[2]; $new_file = $path . "/" . date('Ymd', time()) . "/"; if (!file_exists($new_file)) { mkdir($new_file); } $new_file = $new_file . time() . "." . $type; if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))) { return '/' . $new_file; } else { return false; } } else { return false; } }
/*01.动漫化*/
$obj = $client->selfieAnime($image, $options);
评价:这个动漫化,差强人意。但是人脸这个补丁贴的,只能道一声,唉!
* cartoon:卡通画风格
* pencil:铅笔风格
* color_pencil:彩色铅笔画风格
* warm:彩色糖块油画风格
* wave:神奈川冲浪里油画风格
* lavender:薰衣草油画风格
* mononoke:奇异油画风格
* scream:呐喊油画风格
* gothic:哥特油画风格
*/
$options = array("option" => "cartoon");//替换对应的参数即可
$obj = $client->styleTrans($image, $options);
@lockdata.cn
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。