Skip to main content

Body

This endpoint will crop images intuitively and return the cropped image.
image_url
string
This is the image url of the image you want to crop.
ratio
Integer
This is the ratio of the cropped image. The value could be 9:16 for long vertical, 16:9 for horizontal, 1:1 for square, 4:5 for vertical social media, etc.

Response

cropped_image_url
string
This is the url of the cropped image.
curl -X POST \
  <BASE_URL>/smart-crop-image \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{
    "image_url": "https://example.com/image.jpg",
    "ratio": "4:5"
}'

<?php
$url = '<BASE_URL>/smart-crop-image';
$data = array(
    "image_url" => "https://example.com/image.jpg",
    "ratio" => "4:5"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'X-API-Key: YOUR_API_KEY'
));

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>

import requests

url = '<BASE_URL>/smart-crop-image'
headers = {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY'
}
data = {
    "image_url": "https://example.com/image.jpg",
    "ratio": "4:5"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

const url = '<BASE_URL>/smart-crop-image';
const headers = {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY'
};
const data = {
    "image_url": "https://example.com/image.jpg",
    "ratio": "4:5"
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

{
	"cropped_image_url": "https://example.com/cropped-image.jpeg"
}