AI Lifestyle Crop
POST
/crop/lifestyleAI 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:
curl --location 'https://us1-api.crop.photo/v1/crop/lifestyle' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer :XXX-XXXX-API-KEY' \
--data '{
"image_url": "https://images.unsplash.com/photo-1599382266831-50a19097d81d?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTB8fHJveWFsJTIwZW5maWVsZHxlbnwwfHwwfHx8MA%3D%3D"
"minimum_margins": {
"top": 20,
"bottom": 20,
"left": 50,
"right": 0,
"unit": "px"
},
"output_dimension": "1600x1200",
"output_format": "jpeg",
"response_type": "url"
}
Example 2:
To resize the input image to 3000x2000 with the specified margins, use the API as follows:
curl --location 'https://us1-api.crop.photo/v1/crop/lifestyle' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer :XXX-XXXX-API-KEY' \
--data '{
"image_url": "https://images.unsplash.com/photo-1599382266831-50a19097d81d?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTB8fHJveWFsJTIwZW5maWVsZHxlbnwwfHwwfHx8MA%3D%3D"
"minimum_margins": {
"top": "20",
"bottom": "20",
"left": "50",
"right": "0",
"unit": "px"
},
"output_dimension": "3000x2000",
"output_format": "jpeg",
"response_type": "url"
}
Request
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
- 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
- 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
- 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
- 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
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
Responses
Success(200)
HTTP Code: 200
Content Type : Binaryapplication/octet-stream
ExampleBinary image data
Binary image data
Last modified: 5 months ago