AI Lifestyle Crop
POST
/crop/lifestyle
To resize the input image to a 1600x1200 dimension and with the below mentioned margins in pixels, use the API as follows:
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
.png
, .jpg
, .jpeg
and .webp
, etc. Ensure the URL points directly to a compatible image file.Example:
https://acme.s3.aws.com/image.png
minimum_margins
object (Minimum Margins Lifestyle)
required
top
integer
Top Margin
1
.3000
.>= 1<= 3000
bottom
integer
Bottom Margin
1
.3000
.>= 1<= 3000
left
integer
Left Margin
1
.3000
.>= 1<= 3000
right
integer
Right Margin
1
.3000
.>= 1<= 3000
unit
enum<string>
required
px
for pixels, %
for percentage of the subject's size.Allowed values:
px%
Example:
%
Match pattern:
^(%|px)$
output_format
enum<string>
required
Allowed values:
autojpegpngwebp
Default:
auto
Example:
auto
output_dimension
string
Output Dimension
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 1600x1600Example:
1080x1080
Match pattern:
^(match_to_original|trim_to_subject|(\d{1,4})x(\d{1,4}))$
response_type
enum<string>
required
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.Allowed values:
streamurl
Default:
stream
Example:
stream
ai_model
enum<string>
optional
Allowed values:
SCENE_V1AUTO
Examples:
SCENE_V1AUTO
analysis_hints
array[string]
optional
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}
Example
🟢200Image Crop Response JSON
🟢200Success
🟠401Unauthorized
🟠400Invalid Input | Crop.photo
Modified at 2025-03-18 06:43:58