工具推荐:去掉图像背景生成海报

232 阅读1分钟

1,利用第三方API

api地址: www.remove.bg/api#sample-…


$client = new GuzzleHttp\Client();

$res = $client->post('https://api.remove.bg/v1.0/removebg', [

'multipart' => [

[

'name' => 'image_file',

'contents' => fopen('/path/to/file.jpg', 'r')

],

[

'name' => 'size',

'contents' => 'auto'

]

],

'headers' => [

'X-Api-Key' => 'INSERT_YOUR_API_KEY_HERE'

]

]);

$fp = fopen("no-bg.png", "wb");

fwrite($fp, $res->getBody());

fclose($fp);


这个方案是最简单的,但是比较贵,同时适合小范围使用。

2,利用开源的自建产品

地址: github.com/danielgatis…

Rembg is a tool to remove images background

3,生成海报

第三方api地址: mokker.ai/zh/

picwish.cn

适合小范围使用,直接调用api生成不错的商品海报