Download the PHP package mtownsend/remove-bg without Composer
On this page you can find all versions of the php package mtownsend/remove-bg. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mtownsend/remove-bg
More information about mtownsend/remove-bg
Files in mtownsend/remove-bg
Package remove-bg
Short Description A PHP package to interface with the remove.bg api.
License MIT
Informations about the package remove-bg
Programmatically remove backgrounds from your images using the remove.bg api.
Installation
Install via composer:
This package is designed to work with any PHP 7.0+ application but has special support for Laravel.
Registering the service provider (Laravel users)
For Laravel 5.4 and lower, add the following line to your config/app.php
:
For Laravel 5.5 and greater, the package will auto register the provider for you.
Using Lumen
To register the service provider, add the following line to app/bootstrap/app.php
:
Publishing the config file (Laravel users)
`
Once your removebg.php
has been published your to your config folder, add the api key you obtained from Remove.bg. If you are using Laravel and put your remove.bg api key in the config file, Laravel will automatically set your api key every time you instantiate the class through the helper or facade.
Quick start
Using the class
Advanced usage
Remove.bg offers several request body parameters for each api call. For an up to date list, you should always check the remove.bg api documentation.
Here is an example of an api call configured with specific request body parameters.
``
You may also directly specify request header parameters. As of right now this does not appear to offer much functionality in terms of how the Remove.bg api will consume these headers, but we thought it was important to expose this functionality. Consider the following example:
``
Account details
The Remove.bg api offers an endpoint to check your account's credit balance and free api call usage. If your application needs to check your available credits before processing images this package makes it an absolute breeze!
The following code example is how you can programmatically check your account information. Note, the account
method has one optional argument: $getResponseAsObject = true
. By default your response will be returned as an object. You can return the response as an associative array by passing false
to the account(false)
method.
``
To access your total credits you could do so like this: $account->data->attributes->credits->total
.
A practical example could look something like the following:
``
Using the global helper (Laravel users)
If you are using Laravel, this package provides a convenient helper function which is globally accessible.
Using the facade (Laravel users)
If you are using Laravel, this package provides a facade. To register the facade add the following line to your config/app.php
under the aliases
key.
``
Credits
- Mark Townsend
- All Contributors
Testing
Tests coming soon...
You can run the tests with:
License
The MIT License (MIT). Please see License File for more information.