$ curl -H 'Authorization: Token YOUR_API_KEY'
-F 'file=@/your/image/file.jpg'
-f https://backgroundcut.co/api/v1/cut/
Remove background from image file
$ curl -H 'Authorization: Token YOUR_API_KEY' \
-F 'file=@/your/image/file.jpg' \
-f https://backgroundcut.co/api/v1/cut/
import requests
URL = "https://backgroundcut.co/api/v1/cut/"
PATH = "YOUR_IMAGE_PATH"
image_file = {'file': open(PATH, 'rb')}
headers = {'Authorization': 'Token YOUR_API_KEY'}
response = requests.post(URL, files=image_file, headers=headers)
print(response.json())
// use Guzzle
// https://docs.guzzlephp.org/en/stable/
post("https://backgroundcut.co/api/v1/cut/", [
'multipart' => [
[
'name' => 'file',
'contents' => fopen('SOURCE_IMAGE_FILE_PATH', 'r')
]
],
'headers' => [
'Authorization' => 'Token YOUR_API_KEY'
]
]);
$res_body = $res->getBody()->getContents();
echo $res_body;
?>
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
const imagePath = 'YOUR_IMAGE_PATH'
const settings = {
"endpointPath": "https://backgroundcut.co/api/v1/cut/",
"Authorization": "Token YOUR_API_KEY"
}
function endpointHeader(apiKey, formdata){
return {
headers: {
'Content-Type':'multipart/form-data; boundary=' + formdata.getBoundary(),
'Authorization': 'Token YOUR_API_KEY'
}
}
}
const formdata = new FormData;
formdata.append('file', fs.createReadStream(imagePath));
axios.post(
settings.endpointPath, formdata, endpointHeader(settings.apiKey, formdata)
)
.then(response => console.log(response.data))
.catch(errors => console.log(errors.response.data));
$ curl -H 'Authorization: Token YOUR_API_KEY' \
-F 'file_url=https://www.example.com/example.jpg' \
-f https://backgroundcut.co/api/v1/cut/
import requests
URL = "https://backgroundcut.co/api/v1/cut/"
data={
'file_url': 'https://www.example.com/example.jpg',
}
headers = {'Authorization': 'Token YOUR_API_KEY'}
response = requests.post(URL, data=data, headers=headers)
print(response.json())
// use Guzzle
// https://docs.guzzlephp.org/en/stable/
post("https://slazzer.com/api/v1/remove_image_background", [
'multipart' => [
[
'name' => 'source_image_file',
'contents' => fopen('SOURCE_IMAGE_FILE_PATH', 'r')
]
],
'headers' => [
'API-KEY' => 'YOUR_API_KEY'
]
]);
$res_body = $res->getBody()->getContents();
echo $res_body;
?>
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
const imagePath = 'YOUR_IMAGE_PATH'
const settings = {
"endpointPath": "https://slazzer.com/api/v1/remove_image_background",
"apiKey": "YOUR_API_KEY"
}
function endpointHeader(apiKey, formdata){
return {
headers: {
'Content-Type':'multipart/form-data; boundary=' + formdata.getBoundary(),
'API-KEY': apiKey
}
}
}
const formdata = new FormData;
formdata.append('source_image_file', fs.createReadStream(imagePath));
axios.post(
settings.endpointPath, formdata, endpointHeader(settings.apiKey, formdata)
)
.then(response => console.log(response.data))
.catch(errors => console.log(errors.response.data));
Output Image is provided in 'PNG' format via URL:
Format | Resolution |
---|---|
PNG | Up to 12 Megapixels |
JPG | Up to 12 Megapixels |