draco-development-group / remove-bg
一个非常小的库,用于使用remove.bg API密钥从您的图片中移除背景,并为您提供透明PNG图片
1.0.1
2019-06-25 18:33 UTC
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-09-26 07:20:28 UTC
README
- 您必须从 https://remove.bg 获取API密钥
安装
composer require draco-development-group/remove-bg
快速开始
使用类
// Remember to require the composer autoloader
require_once __DIR__ . '/../vendor/autoload.php';
use DracoDevelopmentGroup\RemoveBg;
$bg = new RemoveBg('YOUR_API_KEY');
$bg->setOutputImageName('path/to/save/new/image/image_name', 'optionalFileType(.jpg or .png)');
$bg->setImageUrl('https://path/to/image.jpg');
$bg->save();
完整文档
您可以从URL设置图片,或直接上传图片,或提供base64编码的图片
- 您只能使用以下之一。如果您在设置图片后尝试使用这些之一,它将保持您最后使用的值。
$bg->setImageUrl(string); $bg->setImageFile(string($binary)); $bg->setImageFileB64(string);
您可以从URL设置背景,或直接上传图片,或提供颜色
- 您只能使用以下之一。如果您在设置图片后尝试使用这些之一,它将保持您最后使用的值。
$bg->setBgColor(string); //can be hex or color name $bg->setBgImageUrl(string); $bg->setBgImageFile(string($binary));
您还可以设置以下参数
$bg->setSize(string); // preview (default), full, auto, etc
$bg->setType(string); //auto, person, product, car
$bg->setFormat(string); //auto, jpg, png
$bg->setRoi(string); //rectangle as x/y coordinates, <x1> <y1> <x2> <y2>
$bg->setCrop(boolean); //default false
$bg->setChannels(string); //rgba default
完整文档也包含在类文件中
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。