Crop.photo
  1. Crop.photo API
Crop.photo
  • Crop.photo API
    • Introduction
    • Authentication
    • FAQs
    • Examples
    • Interactive API Testing
    • Auto Resize & Align
      POST
    • Body Aware Crop
      POST
    • Unrecognizable Crop
      POST
    • Remove Background
      POST
    • Create Banner Job
      POST
    • AI Lifestyle Crop
      POST
    • Banners Job Status
      POST
  1. Crop.photo API

AI Lifestyle Crop

POST
/crop/lifestyle
AI Lifestyle Crop in Crop.photo, is a dedicated feature aimed at optimizing lifestyle photos without altering their backgrounds. This API ensures ensures the object of focus - typically a product - is precisely aligned and sized using the advanced AI algorithms.
Example 1:
To resize the input image to a 1600x1200 dimension and with the below mentioned margins in pixels, use the API as follows:
Example 2:
To resize the input image to 3000x2000 with the specified margins, use the API as follows:

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Body Params application/json
image_url
string <url>
required
Specifies the URL of the image. The URL should be a direct link to the image file, allowing the system to retrieve and process the image as needed.
The URL must be publicly accessible to ensure the system can retrieve the image without authentication barriers.
Supported image formats include .png, .jpg, .jpeg and .webp, etc. Ensure the URL points directly to a compatible image file.
Use a reliable hosting service to prevent issues with image availability or loading times.
This property is essential for operations that require an image as input, facilitating the integration of external images into the workflow.
Example:
https://acme.s3.aws.com/image.png
minimum_margins
object (Minimum Margins Lifestyle) 
required
top
integer 
Top Margin
required
Defines the margin on the top side of the subject.
The margin can be specified as either a percentage of the subject's size or in fixed pixel values.
Minimum value: 1.
Maximum value: 3000.
>= 1<= 3000
bottom
integer 
Bottom Margin
required
Defines the margin on the bottom side of the subject.
Can be defined in either percentage or pixels, similar to the top margin.
Minimum value: 1.
Maximum value: 3000.
>= 1<= 3000
left
integer 
Left Margin
required
Specifies the margin on the left side of the subject.
This margin can also be set in either percentage of the subject's size or in pixels.
Minimum value: 1.
Maximum value: 3000.
>= 1<= 3000
right
integer 
Right Margin
required
Controls the margin on the right side of the subject.
The margin can be provided in percentage or pixels.
Minimum value: 1.
Maximum value: 3000.
>= 1<= 3000
unit
enum<string> 
required
Specifies the unit for the margin values.
Options: px for pixels, % for percentage of the subject's size.
This choice affects all margin definitions.
Allowed values:
px%
Example:
%
Match pattern:
^(%|px)$
output_format
enum<string> 
required
Pick the perfect image format for your cropped images based on your unique needs.
Allowed values:
autojpegpngwebp
Default:
auto
Example:
auto
output_dimension
string 
Output Dimension
required
Possible values are:
match_to_original - Keep original image dimension.
trim_to_subject - Keep subject dimensions with all the given margins around it.
WidthxHeight - Resize the image to given width and height. Like 1600x1600
Example:
1080x1080
Match pattern:
^(match_to_original|trim_to_subject|(\d{1,4})x(\d{1,4}))$
response_type
enum<string> 
required
Specifies the method by which the response is delivered to the client. Available options include:
stream - The response is streamed back in the same request. This option is optimal for immediate processing or display of the data without the need for a separate download step.
url - The response will be provided as a signed S3 URL. This method will be supported in the future and is ideal for cases where the response needs to be accessed multiple times or shared.
Note: Choosing the appropriate response type depends on the use case and the desired workflow for accessing the response data.
Allowed values:
streamurl
Default:
stream
Example:
stream
ai_model
enum<string> 
optional
Specifies which model to be selected for ai based image processing.
Allowed values:
SCENE_V1AUTO
Examples:
SCENE_V1AUTO
analysis_hints
array[string]
optional
Specified which object to look for in the input image
Examples:
housebuilding
Example
{
  "image_url": "https://loremflickr.com/640/480/nightlife",
  "minimum_margins": {
    "top": 2021,
    "bottom": 448,
    "left": 789,
    "right": 414,
    "unit": "px"
  },
  "output_format": "webp",
  "output_dimension": "81x5",
  "response_type": "stream",
  "ai_model": "SCENE_V1",
  "analysis_hints": [
    "sit"
  ]
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://us1-api.crop.photo/v1/crop/lifestyle' \
--header 'Content-Type: application/json' \
--data-raw '{
    "image_url": "https://loremflickr.com/640/480/nightlife",
    "minimum_margins": {
        "top": 2021,
        "bottom": 448,
        "left": 789,
        "right": 414,
        "unit": "px"
    },
    "output_format": "webp",
    "output_dimension": "81x5",
    "response_type": "stream",
    "ai_model": "SCENE_V1",
    "analysis_hints": [
        "sit"
    ]
}'

Responses

🟢200Binary Octel Stream Response
application/octet-stream
Body
object {0}
🟢200Image Crop Response JSON
🟢200Success
🟠401Unauthorized
🟠400Invalid Input | Crop.photo
Modified at 2025-03-18 06:43:58
Previous
Create Banner Job
Next
Banners Job Status
Built with