curl --request POST \
--url https://api.magnific.com/v1/ai/beta/remove-background \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-magnific-api-key: <api-key>' \
--data 'image_url=https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469'import requests
url = "https://api.magnific.com/v1/ai/beta/remove-background"
payload = { "image_url": "https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469" }
headers = {
"x-magnific-api-key": "<api-key>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-magnific-api-key': '<api-key>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
image_url: 'https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469'
})
};
fetch('https://api.magnific.com/v1/ai/beta/remove-background', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magnific.com/v1/ai/beta/remove-background",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded",
"x-magnific-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magnific.com/v1/ai/beta/remove-background"
payload := strings.NewReader("image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-magnific-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magnific.com/v1/ai/beta/remove-background")
.header("x-magnific-api-key", "<api-key>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magnific.com/v1/ai/beta/remove-background")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-magnific-api-key"] = '<api-key>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469"
response = http.request(request)
puts response.read_body{
"original": "https://api.magnific.com/v1/ai/beta/images/original/037ea4ea-e8ad84a8c7/thumbnail.jpg",
"high_resolution": "https://api.magnific.com/v1/ai/beta/images/download/037ead-44cd8ad84a8c7/high.png",
"preview": "https://api.magnific.com/v1/ai/beta/images/download/037ea4eacad84a8c7/preview.png",
"url": "https://api.magnific.com/v1/ai/beta/images/download/037ea4ea-720d-411e8ad84a8c7/high.png"
}Remove the background of an image
This endpoint removes the background from an image provided via a URL. The URLs in the response are temporary and valid for 5 minutes only.
Supported formats: JPG, PNG
File size limit: up to 20 MB
Output resolutions: Preview (up to 0.25 megapixels), Full resolution (up to 25 megapixels)
curl --request POST \
--url https://api.magnific.com/v1/ai/beta/remove-background \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-magnific-api-key: <api-key>' \
--data 'image_url=https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469'import requests
url = "https://api.magnific.com/v1/ai/beta/remove-background"
payload = { "image_url": "https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469" }
headers = {
"x-magnific-api-key": "<api-key>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-magnific-api-key': '<api-key>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
image_url: 'https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469'
})
};
fetch('https://api.magnific.com/v1/ai/beta/remove-background', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magnific.com/v1/ai/beta/remove-background",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded",
"x-magnific-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magnific.com/v1/ai/beta/remove-background"
payload := strings.NewReader("image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-magnific-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magnific.com/v1/ai/beta/remove-background")
.header("x-magnific-api-key", "<api-key>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magnific.com/v1/ai/beta/remove-background")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-magnific-api-key"] = '<api-key>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "image_url=https%3A%2F%2Fimg.freepik.com%2Ffree-vector%2Fcute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg%3Fw%3D2000%26t%3Dst%3D1725353998~exp%3D1725357598~hmac%3Da17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469"
response = http.request(request)
puts response.read_body{
"original": "https://api.magnific.com/v1/ai/beta/images/original/037ea4ea-e8ad84a8c7/thumbnail.jpg",
"high_resolution": "https://api.magnific.com/v1/ai/beta/images/download/037ead-44cd8ad84a8c7/high.png",
"preview": "https://api.magnific.com/v1/ai/beta/images/download/037ea4eacad84a8c7/preview.png",
"url": "https://api.magnific.com/v1/ai/beta/images/download/037ea4ea-720d-411e8ad84a8c7/high.png"
}Authorizations
Your Magnific API key. Required for authentication. Learn how to obtain an API key
Body
The URL of the image whose background needs to be removed.
"https://img.freepik.com/free-vector/cute-cat-sitting-cartoon-vector-icon-illustration-animal-nature-icon-concept-isolated-premium-vector-flat-cartoon-style_138676-4148.jpg?w=2000&t=st=1725353998~exp=1725357598~hmac=a17f90afeeff454b36c0715f84eed2b388cd9c4a7ce59fcdff075fa41770e469"
Response
Successful background removal.
Was this page helpful?