draco-development-group / remove-bg
A very small library to use your remove.bg api key to remove the background from your images and give you a transparent 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: 2025-05-26 08:52:37 UTC
README
- You must get an api key from https://remove.bg
To install:
composer require draco-development-group/remove-bg
Quick Start:
Use the class
// 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();
Full Documentation
You can set images from urls, or directly upload the image, or give a base64_encoded image:
- You may only use one of the following. If you attempt to use one of these after already setting an image, it will keep the last value you used.
$bg->setImageUrl(string); $bg->setImageFile(string($binary)); $bg->setImageFileB64(string);
You can set backgrounds from urls, or directly upload the image, or give a color:
- You may only use one of the following. If you attempt to use one of these after already setting an image, it will keep the last value you used.
$bg->setBgColor(string); //can be hex or color name $bg->setBgImageUrl(string); $bg->setBgImageFile(string($binary));
You can set the following parameters as well
$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
Full documentation also available in the class file
License
The MIT License (MIT). Please see License File for more information.