Install the rembg Python CLI tool:
pip install rembg[cli]Then install PHP dependencies:
composer installInstall PHP dependencies and download the model:
composer install
./vendor/bin/transformers download "briaai/RMBG-1.4"Enable the ffi extension in your php.ini file:
ffi.enable = true
You can remove the background of an image on the fly via url.
For example, your image is https://example.com/image.jpg you can remove the background by appending this app url to the image url:
https://remove-bg.test/example.com/image.jpg
By default, PHP Transformers is used. You can switch to rembg via the driver query string:
https://remove-bg.test/example.com/image.jpg?driver=rembg
Enjoy!